Skip to content

Commit 7209ba3

Browse files
authored
Merge pull request apache#63 from mesosphere/go-cli
Implement a Go Spark CLI
2 parents 238f921 + 954c371 commit 7209ba3

39 files changed

+813
-1295
lines changed

bin/build.sh

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# - stub universe zip to S3
77
#
88
# Manifest config:
9-
# cli_version - version label to use for CLI package
109
# spark_uri - where fetch spark distribution from (or SPARK_DIST_URI if provided)
1110
#
1211
# ENV vars:
@@ -27,13 +26,6 @@ configure_env() {
2726
echo "Using Spark dist URI: $SPARK_DIST_URI"
2827
fi
2928

30-
if [ -z "${CLI_VERSION}" ]; then
31-
CLI_VERSION=$(cat $BASEDIR/manifest.json | jq .cli_version)
32-
CLI_VERSION="${CLI_VERSION%\"}"
33-
CLI_VERSION="${CLI_VERSION#\"}"
34-
echo "Using CLI Version: $CLI_VERSION"
35-
fi
36-
3729
if [ -z "$DOCKER_IMAGE" ]; then
3830
# determine image label based on git commit:
3931
if [ -n "$ghprbActualCommit" ]; then
@@ -68,7 +60,7 @@ notify_github() {
6860

6961
build_cli() {
7062
notify_github pending "Building CLI"
71-
CLI_VERSION=$CLI_VERSION make --directory=$BASEDIR/cli env test packages
63+
make --directory=$BASEDIR/cli all
7264
if [ $? -ne 0 ]; then
7365
notify_github failure "CLI build failed"
7466
exit 1
@@ -91,17 +83,19 @@ upload_cli_and_stub_universe() {
9183
# Build/upload package using custom template parameters: TEMPLATE_X_Y_Z => {{x-y-z}}
9284
TEMPLATE_SPARK_DIST_URI=${SPARK_DIST_URI} \
9385
TEMPLATE_DOCKER_IMAGE=${DOCKER_IMAGE} \
94-
TEMPLATE_CLI_VERSION=${CLI_VERSION} \
9586
TEMPLATE_PACKAGE_VERSION=${VERSION} \
96-
ARTIFACT_DIR="https://downloads.mesosphere.com/spark/assets" \
87+
ARTIFACT_DIR="https://${S3_BUCKET}.s3.amazonaws.com/${S3_PREFIX}" \
9788
S3_URL="s3://${S3_BUCKET}/${S3_PREFIX}" \
9889
${COMMONS_TOOLS_DIR}/ci_upload.py \
9990
spark \
10091
${BASEDIR}/package/ \
101-
${BASEDIR}/cli/dist/*.whl
92+
${BASEDIR}/cli/dcos-spark/dcos-spark-darwin \
93+
${BASEDIR}/cli/dcos-spark/dcos-spark-linux \
94+
${BASEDIR}/cli/dcos-spark/dcos-spark.exe \
95+
${BASEDIR}/cli/python/dist/*.whl
10296
}
10397

104-
# set CLI_VERSION, SPARK_URI, and DOCKER_IMAGE:
98+
# set SPARK_URI and DOCKER_IMAGE:
10599
configure_env
106100

107101
fetch_commons_tools

bin/jenkins-package-test.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
#!/bin/bash
22

3+
export VERSION=${ghprbActualCommit}
4+
if [ -z "$VERSION" ]; then
5+
export VERSION=${GIT_COMMIT}
6+
fi
7+
8+
export DOCKER_IMAGE=mesosphere/spark-dev:${VERSION}
9+
310
export S3_BUCKET=infinity-artifacts
4-
export S3_PREFIX=spark/
5-
export DOCKER_IMAGE=mesosphere/spark-dev:${GIT_COMMIT}
11+
export S3_PREFIX=autodelete7d/spark/${VERSION}
12+
# fill in any missing DEV_* AWS envvars required by test.sh:
13+
if [ -z "$DEV_S3_BUCKET" ]; then
14+
export DEV_S3_BUCKET=$S3_BUCKET
15+
fi
16+
if [ -z "$DEV_S3_PREFIX" ]; then
17+
export DEV_S3_PREFIX=$S3_PREFIX
18+
fi
19+
if [ -z "$DEV_AWS_ACCESS_KEY_ID" ]; then
20+
export DEV_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
21+
fi
22+
if [ -z "$DEV_AWS_SECRET_ACCESS_KEY" ]; then
23+
export DEV_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
24+
fi
625

726
source spark-build/bin/jenkins.sh
827

bin/jenkins.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ function spark_test {
9898
# run tests against build artifacts:
9999
CLUSTER_NAME=spark-package-${BUILD_NUMBER} \
100100
TEST_DIR=$(pwd)/../mesos-spark-integration-tests/ \
101-
DCOS_CHANNEL=testing/master \
102-
DCOS_USERNAME=bootstrapuser \
103-
DCOS_PASSWORD=deleteme \
104101
S3_BUCKET=${DEV_S3_BUCKET} \
105102
S3_PREFIX=${DEV_S3_PREFIX} \
106103
make test

bin/test.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1111
check_env() {
1212
# Check env early, before starting the cluster:
1313
if [ -z "$DOCKER_IMAGE" \
14-
-o -z "$DCOS_USERNAME" \
15-
-o -z "$DCOS_PASSWORD" \
1614
-o -z "$STUB_UNIVERSE_URL" \
1715
-o -z "$AWS_ACCESS_KEY_ID" \
1816
-o -z "$AWS_SECRET_ACCESS_KEY" \
@@ -56,15 +54,8 @@ start_cluster() {
5654
configure_cli() {
5755
notify_github pending "Configuring CLI"
5856

59-
# EE
60-
#TOKEN=$(python -c "import requests;js={'uid':'"${DCOS_USERNAME}"', 'password': '"${DCOS_PASSWORD}"'};r=requests.post('"${DCOS_URL}"/acs/api/v1/auth/login',json=js);print(r.json()['token'])")
61-
62-
# # Open
63-
# TOKEN=$(python -c "import requests; import sys; js = {'token':'"${DCOS_OAUTH_TOKEN}"'}; r=requests.post('"${DCOS_URL}"/acs/api/v1/auth/login',json=js); sys.stderr.write(str(r.json())); print(r.json()['token'])")
64-
65-
# dcos config set core.dcos_acs_token "${TOKEN}"
66-
6757
dcos config set core.dcos_url "${DCOS_URL}"
58+
dcos config set core.ssl_verify false
6859
${COMMONS_TOOLS_DIR}/dcos_login.py
6960
dcos config show
7061
dcos package repo add --index=0 spark-test "${STUB_UNIVERSE_URL}"
@@ -114,6 +105,10 @@ run_tests() {
114105
S3_PREFIX=${DEV_S3_PREFIX} \
115106
TEST_JAR_PATH=${TEST_JAR_PATH} \
116107
python test.py
108+
if [ $? -ne 0 ]; then
109+
notify_github failure "Tests failed"
110+
exit 1
111+
fi
117112
popd
118113
}
119114

cli/Makefile

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
all: env test binary
1+
all: go python-wrapper
22

3+
go:
4+
bin/build-go.sh
5+
python-wrapper: go
6+
bin/build-python-wrapper.sh
37
clean:
48
bin/clean.sh
5-
6-
env: clean
7-
bin/env.sh
8-
9-
test:
10-
bin/test.sh
11-
12-
packages:
13-
bin/packages.sh
14-
15-
binary: env
16-
pyinstaller binary/binary.spec
17-
18-
.PHONY: binary

cli/README.rst

Lines changed: 0 additions & 99 deletions
This file was deleted.

cli/bin/binary.sh

Lines changed: 0 additions & 58 deletions
This file was deleted.

cli/bin/build-go.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
set +x
4+
5+
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
cd "$BIN_DIR"/..
7+
8+
if [ -z "$GOPATH" -o -z "$(which go)" ]; then
9+
echo "Missing GOPATH environment variable or 'go' executable. Please configure a Go build environment."
10+
exit 1
11+
fi
12+
13+
# The name of the binary produced by Go:
14+
if [ -z "$EXE_NAME" ]; then
15+
EXE_NAME="dcos-spark"
16+
fi
17+
18+
print_file() {
19+
# Only show 'file <filename>' if that utility is available: often missing in CI builds.
20+
if [ -n "$(which file)" ]; then
21+
file "$1"
22+
fi
23+
ls -l "$1"
24+
echo ""
25+
}
26+
27+
# ---
28+
29+
# go (static binaries containing the CLI itself)
30+
cd $EXE_NAME/
31+
32+
# this may be omitted in 1.6+, left here for compatibility with 1.5:
33+
export GO15VENDOREXPERIMENT=1
34+
35+
go get
36+
37+
# available GOOS/GOARCH permutations are listed at:
38+
# https://golang.org/doc/install/source#environment
39+
40+
# windows:
41+
GOOS=windows GOARCH=386 go build
42+
print_file "${EXE_NAME}.exe"
43+
44+
# osx (static build):
45+
SUFFIX="-darwin"
46+
CGO_ENABLED=0 GOOS=darwin GOARCH=386 go build \
47+
&& mv -vf "${EXE_NAME}" "${EXE_NAME}${SUFFIX}"
48+
# don't ever strip the darwin binary: results in a broken/segfaulty build
49+
print_file "${EXE_NAME}${SUFFIX}"
50+
51+
# linux (static build):
52+
SUFFIX="-linux"
53+
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build \
54+
&& mv -vf "${EXE_NAME}" "${EXE_NAME}${SUFFIX}"
55+
case "$OSTYPE" in
56+
linux*) strip "${EXE_NAME}${SUFFIX}"
57+
esac
58+
print_file "${EXE_NAME}${SUFFIX}"

cli/bin/build-python-wrapper.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set +x
4+
5+
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
cd $BIN_DIR/../python/
7+
8+
print_file() {
9+
# Only show 'file <filename>' if that utility is available: often missing in CI builds.
10+
if [ -n "$(which file)" ]; then
11+
file "$1"
12+
fi
13+
ls -l "$1"
14+
echo ""
15+
}
16+
17+
python setup.py bdist_wheel
18+
print_file dist/*.whl

0 commit comments

Comments
 (0)