Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit e575fd3

Browse files
authored
Add Dispatch Solo OVA release pipeline (#725)
Pipeline tracks version and triggers e2e tests for every version bump. Revision that passes tests is then used to build an OVA. OVA is stored on an S3 bucket. There is also a Github release created for that version. Also changes the API e2e tests to use default timeout and retry values (previous values were too low and caused tests failures despite the gateway functioning correctly)
1 parent db158b8 commit e575fd3

File tree

6 files changed

+64
-33
lines changed

6 files changed

+64
-33
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ cli-darwin:
119119
cli-linux:
120120
GOOS=linux go build -ldflags "$(GO_LDFLAGS) $(CLI_LDFLAGS)" -o bin/$(CLI)-linux ./cmd/$(CLI)
121121

122+
.PHONY: binaries
123+
binaries: linux darwin
124+
122125
.PHONY: toolbox
123126
toolbox:
124127
GOOS=linux go build -ldflags "$(GO_LDFLAGS) $(CLI_LDFLAGS)" -o bin/toolbox ./cmd/toolbox

ci/pipelines/ova-release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ resources:
3131
source:
3232
initial_version: 0.0.1
3333
bucket: ((s3-ci-bucket-name))
34-
key: solo-version
34+
key: dispatch-solo-version
3535
region_name: ((s3-ci-bucket-region-name))
3636
access_key_id: ((s3-ci-bucket-access-key))
3737
secret_access_key: ((s3-ci-bucket-secret-key))
@@ -98,7 +98,7 @@ jobs:
9898
params:
9999
file: dispatch-logs/*.tar.gz
100100

101-
- name: build-ova
101+
- name: release
102102
public: true
103103
plan:
104104
- get: version
@@ -108,6 +108,17 @@ jobs:
108108
- get: dispatch
109109
resource: dispatch-solo
110110
passed: [test-dispatch-solo]
111+
- task: prepare-version
112+
file: dispatch/ci/tasks/prepare-version.yml
113+
- task: build-binaries
114+
file: dispatch/ci/tasks/binaries.yml
115+
- put: gh-release
116+
params:
117+
name: release-context/tag
118+
tag: release-context/tag
119+
commitish: release-context/branch
120+
globs:
121+
- dispatch-binaries/dispatch-*
111122
- task: build-ova
112123
file: dispatch/ci/tasks/build-ova.yml
113124
privileged: true

ci/tasks/binaries.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
- name: dispatch
1212
path: src/github.com/vmware/dispatch
1313

14+
- name: release-context
15+
optional: true
16+
1417
outputs:
1518
- name: dispatch-binaries
1619

@@ -22,6 +25,9 @@ run:
2225
set -e -u -x
2326
2427
export GOPATH=$PWD
28+
if [[ -e release-context/tag ]]; then
29+
export VERSION=$(cat release-context/tag)
30+
fi
2531
cd $GOPATH/src/github.com/vmware/dispatch
26-
make linux
32+
make binaries
2733
mv bin/* $GOPATH/dispatch-binaries/

ci/tasks/build-ova.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inputs:
1010
- name: dispatch
1111
path: src/github.com/vmware/dispatch
1212

13+
- name: release-context
14+
optional: true
15+
1316
outputs:
1417
- name: dispatch-ova
1518

@@ -53,6 +56,13 @@ run:
5356
5457
5558
export GOPATH=$PWD
59+
60+
export GOPATH=$PWD
61+
if [[ -e release-context/tag ]]; then
62+
export VERSION=$(cat release-context/tag)
63+
export TAG=${VERSION}
64+
fi
65+
5666
cd $GOPATH/src/github.com/vmware/dispatch
5767
make ova-binaries
5868
pushd ova

ci/tasks/prepare-version.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
- name: version
1212

1313
outputs:
14-
- name: build-context
14+
- name: release-context
1515

1616
run:
1717
path: /bin/bash
@@ -21,4 +21,5 @@ run:
2121
set -e -x -u
2222
2323
export IMAGE_TAG=v$(cat version/version)-solo
24-
echo ${IMAGE_TAG} > build-context/tag
24+
echo ${IMAGE_TAG} > release-context/tag
25+
echo solo > release-context/branch

e2e/tests/apis.bats

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,147 +12,147 @@ load variables
1212

1313
run dispatch create base-image base-nodejs $DOCKER_REGISTRY/$BASE_IMAGE_NODEJS6 --language nodejs
1414
assert_success
15-
run_with_retry "dispatch get base-image base-nodejs -o json | jq -r .status" "READY" 8 2
15+
run_with_retry "dispatch get base-image base-nodejs -o json | jq -r .status" "READY"
1616

1717
run dispatch create image nodejs base-nodejs
1818
assert_success
19-
run_with_retry "dispatch get image nodejs -o json | jq -r .status" "READY" 8 2
19+
run_with_retry "dispatch get image nodejs -o json | jq -r .status" "READY"
2020
}
2121

2222
@test "Create Functions for test" {
2323
run dispatch create function --image=nodejs func-nodejs ${DISPATCH_ROOT}/examples/nodejs --handler=./hello.js
2424
echo_to_log
2525
assert_success
2626

27-
run_with_retry "dispatch get function func-nodejs -o json | jq -r .status" "READY" 10 2
27+
run_with_retry "dispatch get function func-nodejs -o json | jq -r .status" "READY"
2828

2929
run dispatch create function --image=nodejs node-echo-back ${DISPATCH_ROOT}/examples/nodejs --handler=./debug.js
3030
echo_to_log
3131
assert_success
3232

33-
run_with_retry "dispatch get function node-echo-back -o json | jq -r .status" "READY" 10 2
33+
run_with_retry "dispatch get function node-echo-back -o json | jq -r .status" "READY"
3434
}
3535

3636
@test "Test APIs with HTTP(S)" {
3737
run dispatch create api api-test-http func-nodejs -m POST -p /http --auth public
3838
echo_to_log
3939
assert_success
4040

41-
run_with_retry "dispatch get api api-test-http -o json | jq -r .status" "READY" 10 2
41+
run_with_retry "dispatch get api api-test-http -o json | jq -r .status" "READY"
4242

4343
echo "${API_GATEWAY_HTTPS_HOST}"
4444

4545
run_with_retry "curl -s -X POST ${API_GATEWAY_HTTP_HOST}/${DISPATCH_ORGANIZATION}/http -H \"Content-Type: application/json\" -d '{
4646
\"name\": \"VMware\",
4747
\"place\": \"HTTP\"
48-
}' | jq -r .myField" "Hello, VMware from HTTP" 6 2
48+
}' | jq -r .myField" "Hello, VMware from HTTP"
4949

5050
run_with_retry "curl -s -X POST ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/http -k -H \"Content-Type: application/json\" -d '{
5151
\"name\": \"VMware\",
5252
\"place\": \"HTTPS\"
53-
}' | jq -r .myField" "Hello, VMware from HTTPS" 6 2
53+
}' | jq -r .myField" "Hello, VMware from HTTPS"
5454
}
5555

5656
@test "Test APIs with HTTPS ONLY" {
5757
run dispatch create api api-test-https-only func-nodejs -m POST --https-only -p /https-only --auth public
5858
echo_to_log
5959
assert_success
60-
run_with_retry "dispatch get api api-test-https-only -o json | jq -r .status" "READY" 6 2
60+
run_with_retry "dispatch get api api-test-https-only -o json | jq -r .status" "READY"
6161

6262
run_with_retry "curl -s -X POST ${API_GATEWAY_HTTP_HOST}/${DISPATCH_ORGANIZATION}/https-only -H \"Content-Type: application/json\" -d '{ \
6363
\"name\": \"VMware\",
6464
\"place\": \"HTTPS ONLY\"
65-
}' | jq -r .message" "Please use HTTPS protocol" 6 2
65+
}' | jq -r .message" "Please use HTTPS protocol"
6666

6767
run_with_retry "curl -s -X POST ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/https-only -k -H \"Content-Type: application/json\" -d '{ \
6868
\"name\": \"VMware\",
6969
\"place\": \"HTTPS ONLY\"
70-
}' | jq -r .myField" "Hello, VMware from HTTPS ONLY" 6 2
70+
}' | jq -r .myField" "Hello, VMware from HTTPS ONLY"
7171
}
7272

7373
@test "Test APIs with Kong Plugins" {
7474

7575
run dispatch create api api-test func-nodejs -m GET -m DELETE -m POST -m PUT -p /hello --auth public
7676
echo_to_log
7777
assert_success
78-
run_with_retry "dispatch get api api-test -o json | jq -r .status" "READY" 6 2
78+
run_with_retry "dispatch get api api-test -o json | jq -r .status" "READY"
7979

8080
run dispatch create api api-echo node-echo-back -m GET -m DELETE -m POST -m PUT -p /echo --auth public
8181
echo_to_log
8282
assert_success
83-
run_with_retry "dispatch get api api-echo -o json | jq -r .status" "READY" 6 2
83+
run_with_retry "dispatch get api api-echo -o json | jq -r .status" "READY"
8484

8585
# "x-dispatch-blocking: true" is default header
8686
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k -H \"Content-Type: application/json\" -d '{ \
8787
\"name\": \"VMware\",
8888
\"place\": \"Palo Alto\"
89-
}' | jq -r .myField" "Hello, VMware from Palo Alto" 6 2
89+
}' | jq -r .myField" "Hello, VMware from Palo Alto"
9090

9191
# with "x-dispatch-blocking: false", it will not return an result
9292
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k -H \"Content-Type: application/json\" -H 'x-dispatch-blocking: false' -d '{
9393
\"name\": \"VMware\",
9494
\"place\": \"Palo Alto\"
95-
}'" "" 6 2
95+
}'" ""
9696

9797
# with "x-dispatch-org: invalid", setting this header should have no effect as it's overwritten by the plugin.
9898
# if the plugin fails to overwrite this HEADER, it will allow end-users to switch orgs and this test should fail
9999
# with {"message":"function not found"}.
100100
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k -H \"Content-Type: application/json\" -H 'x-dispatch-org: invalid' -d '{
101101
\"name\": \"VMware\",
102102
\"place\": \"Palo Alto\"
103-
}' | jq -r .myField" "Hello, VMware from Palo Alto" 6 2
103+
}' | jq -r .myField" "Hello, VMware from Palo Alto"
104104

105105
# PUT with no content-type and no payload
106-
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k | jq -r .myField" "Hello, Noone from Nowhere" 6 2
106+
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k | jq -r .myField" "Hello, Noone from Nowhere"
107107

108108
# PUT with json content-type and non-json payload
109109
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k \
110-
-H \"Content-Type: application/json\" -d \"not a json payload\" | jq -r .message" "request body is not json" 6 2
110+
-H \"Content-Type: application/json\" -d \"not a json payload\" | jq -r .message" "request body is not json"
111111

112112
# PUT with x-www-form-urlencoded content-type and x-www-form-urlencoded payload
113113
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k \
114-
-H \"Content-Type: application/x-www-form-urlencoded\" -d \"name=VMware&place=Palo Alto\" | jq -r .myField" "Hello, VMware from Palo Alto" 6 2
114+
-H \"Content-Type: application/x-www-form-urlencoded\" -d \"name=VMware&place=Palo Alto\" | jq -r .myField" "Hello, VMware from Palo Alto"
115115

116116
# PUT with non-supported content-type and payload
117117
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k \
118-
-H \"Content-Type: unsupported-content-type\" -d \"some payload\" | jq -r .message" "request body type is not supported: unsupported-content-type" 6 2
118+
-H \"Content-Type: unsupported-content-type\" -d \"some payload\" | jq -r .message" "request body type is not supported: unsupported-content-type"
119119

120120
# GET with parameters
121-
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello?name=vmware\&place=PaloAlto -k | jq -r .myField" "Hello, vmware from PaloAlto" 6 2
121+
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello?name=vmware\&place=PaloAlto -k | jq -r .myField" "Hello, vmware from PaloAlto"
122122

123123
# GET without parameters
124-
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k | jq -r .myField" "Hello, Noone from Nowhere" 6 2
124+
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/hello -k | jq -r .myField" "Hello, Noone from Nowhere"
125125

126126
# Test HTTP Context
127-
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/echo -k | jq -r .context.httpContext.method" "PUT" 6 2
127+
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/echo -k | jq -r .context.httpContext.method" "PUT"
128128
}
129129

130130
@test "Test APIs with CORS" {
131131
run dispatch create api api-test-cors func-nodejs -m POST -m PUT -p /cors --auth public --cors
132132
echo_to_log
133133
assert_success
134-
run_with_retry "dispatch get api api-test-cors -o json | jq -r .status" "READY" 10 2
134+
run_with_retry "dispatch get api api-test-cors -o json | jq -r .status" "READY"
135135

136136
# contains "Access-Control-Allow-Origin: *"
137137
run_with_retry "curl -s -X PUT ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/cors -k -v -H \"Content-Type: application/json\" -d '{
138138
\"name\": \"VMware\",
139139
\"place\": \"Palo Alto\"
140-
}' 2>&1 | grep -c \"Access-Control-Allow-Origin: *\"" 1 10 2
140+
}' 2>&1 | grep -c \"Access-Control-Allow-Origin: *\"" 1
141141
}
142142

143143
@test "Test API Updates" {
144144
run dispatch create api api-test-update func-nodejs -m GET -p /hello --auth public
145145
assert_success
146-
run_with_retry "dispatch get api api-test-update -o json | jq -r .status" "READY" 6 2
146+
run_with_retry "dispatch get api api-test-update -o json | jq -r .status" "READY"
147147

148-
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTP_HOST}/${DISPATCH_ORGANIZATION}/hello -k | jq -r .myField" "Hello, Noone from Nowhere" 6 5
148+
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTP_HOST}/${DISPATCH_ORGANIZATION}/hello -k | jq -r .myField" "Hello, Noone from Nowhere"
149149

150150
# update path and https
151151
run dispatch update --work-dir ${BATS_TEST_DIRNAME} -f api_update.yaml
152152
assert_success
153-
run_with_retry "dispatch get api api-test-update -o json | jq -r .status" "READY" 6 2
153+
run_with_retry "dispatch get api api-test-update -o json | jq -r .status" "READY"
154154

155-
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/goodbye -k | jq -r .myField" "Hello, Noone from Nowhere" 6 5
155+
run_with_retry "curl -s -X GET ${API_GATEWAY_HTTPS_HOST}/${DISPATCH_ORGANIZATION}/goodbye -k | jq -r .myField" "Hello, Noone from Nowhere"
156156
}
157157

158158
@test "Cleanup" {

0 commit comments

Comments
 (0)