33source test/e2e/helpers.sh
44
55setup () {
6- load ' bats/support/load'
7- load ' bats/assert/load'
8- load ' bats/file/load'
6+ load ' bats/support/load'
7+ load ' bats/assert/load'
8+ load ' bats/file/load'
99}
1010
1111teardown () {
12- run kubectl delete builds.shipwright.io --all
13- run kubectl delete buildruns.shipwright.io --all
12+ run kubectl delete builds.shipwright.io --all
13+ run kubectl delete buildruns.shipwright.io --all
1414}
1515
16+ scheduler_name=" dolphinscheduler"
17+
1618@test " shp build create --node-selector single label" {
1719 # generate random names for our build
18- build_name=$( random_name)
20+ build_name=$( random_name)
1921
20- # create a Build with node selector
22+ # create a Build with node selector
2123 run shp build create ${build_name} --source-git-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image --node-selector=" kubernetes.io/hostname=node-1"
2224 assert_success
2325
2426 # ensure that the build was successfully created
25- assert_output --partial " Created build \" ${build_name} \" "
27+ assert_output --partial " Created build \" ${build_name} \" "
2628
2729 # get the jsonpath of Build object .spec.nodeSelector
28- run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.nodeSelector}"
29- assert_success
30+ run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.nodeSelector}"
31+ assert_success
3032
3133 assert_output ' {"kubernetes.io/hostname":"node-1"}'
3234}
3335
3436@test " shp build create --node-selector multiple labels" {
3537 # generate random names for our build
36- build_name=$( random_name)
38+ build_name=$( random_name)
3739
38- # create a Build with node selector
39- run shp build create ${build_name} --source-git-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image --node-selector=" kubernetes.io/hostname=node-1" --node-selector=" kubernetes.io/os=linux"
40+ # create a Build with node selector
41+ run shp build create ${build_name} --source-git-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image --node-selector=" kubernetes.io/hostname=node-1" --node-selector=" kubernetes.io/os=linux"
4042 assert_success
4143
4244 # ensure that the build was successfully created
43- assert_output --partial " Created build \" ${build_name} \" "
45+ assert_output --partial " Created build \" ${build_name} \" "
4446
4547 # get the jsonpath of Build object .spec.nodeSelector
46- run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.nodeSelector}"
47- assert_success
48+ run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.nodeSelector}"
49+ assert_success
4850
4951 assert_output --partial ' "kubernetes.io/hostname":"node-1"'
5052 assert_output --partial ' "kubernetes.io/os":"linux"'
5153}
5254
55+ @test " shp build create --scheduler-name" {
56+ # generate random names for our build
57+ build_name=$( random_name)
58+
59+ # create a Build with node selector
60+ run shp build create ${build_name} --source-git-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image --scheduler-name=${scheduler_name}
61+ assert_success
62+
63+ # ensure that the build was successfully created
64+ assert_output --partial " Created build \" ${build_name} \" "
65+
66+ # get the jsonpath of Build object .spec.nodeSelector
67+ run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.schedulerName}"
68+ assert_success
69+
70+ assert_output " ${scheduler_name} "
71+ }
72+
5373@test " shp buildrun create --node-selector single label" {
5474 # generate random names for our buildrun
55- buildrun_name=$( random_name)
56- build_name=$( random_name)
75+ buildrun_name=$( random_name)
76+ build_name=$( random_name)
5777
58- # create a Build with node selector
78+ # create a Build with node selector
5979 run shp buildrun create ${buildrun_name} --buildref-name=${build_name} --node-selector=" kubernetes.io/hostname=node-1"
6080 assert_success
6181
6282 # ensure that the build was successfully created
63- assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
83+ assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
6484
6585 # get the jsonpath of Build object .spec.nodeSelector
66- run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.nodeSelector}"
67- assert_success
86+ run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.nodeSelector}"
87+ assert_success
6888
6989 assert_output ' {"kubernetes.io/hostname":"node-1"}'
7090}
7191
7292@test " shp buildrun create --node-selector multiple labels" {
7393 # generate random names for our buildrun
74- buildrun_name=$( random_name)
75- build_name=$( random_name)
94+ buildrun_name=$( random_name)
95+ build_name=$( random_name)
7696
77- # create a Build with node selector
78- run shp buildrun create ${buildrun_name} --buildref-name=${build_name} --node-selector=" kubernetes.io/hostname=node-1" --node-selector=" kubernetes.io/os=linux"
97+ # create a Build with node selector
98+ run shp buildrun create ${buildrun_name} --buildref-name=${build_name} --node-selector=" kubernetes.io/hostname=node-1" --node-selector=" kubernetes.io/os=linux"
7999 assert_success
80100
81101 # ensure that the build was successfully created
82- assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
102+ assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
83103
84104 # get the jsonpath of Build object .spec.nodeSelector
85- run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.nodeSelector}"
86- assert_success
105+ run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.nodeSelector}"
106+ assert_success
87107
88108 assert_output --partial ' "kubernetes.io/hostname":"node-1"'
89109 assert_output --partial ' "kubernetes.io/os":"linux"'
90110}
91111
112+ @test " shp buildrun create --scheduler-name" {
113+ # generate random names for our buildrun
114+ buildrun_name=$( random_name)
115+ build_name=$( random_name)
116+
117+ # create a Build with node selector
118+ run shp buildrun create ${buildrun_name} --buildref-name=${build_name} --scheduler-name=${scheduler_name}
119+ assert_success
120+
121+ # ensure that the build was successfully created
122+ assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
123+
124+ # get the jsonpath of Build object .spec.nodeSelector
125+ run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.schedulerName}"
126+ assert_success
127+
128+ assert_output " ${scheduler_name} "
129+ }
92130
93131@test " shp build run --node-selector set" {
94132 # generate random names for our build
95- build_name=$( random_name)
133+ build_name=$( random_name)
96134
97- # create a Build with node selector
135+ # create a Build with node selector
98136 run shp build create ${build_name} --source-git-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image
99137 assert_success
100138
101139 # ensure that the build was successfully created
102- assert_output --partial " Created build \" ${build_name} \" "
140+ assert_output --partial " Created build \" ${build_name} \" "
103141
104142 # get the build object
105- run kubectl get builds.shipwright.io/${build_name}
106- assert_success
143+ run kubectl get builds.shipwright.io/${build_name}
144+ assert_success
107145
108146 run shp build run ${build_name} --node-selector=" kubernetes.io/hostname=node-1"
109147
110148 # get the jsonpath of Build object .spec.nodeSelector
111- run kubectl get buildruns.shipwright.io -ojsonpath=' {.items[*].spec.nodeSelector}'
112- assert_success
149+ run kubectl get buildruns.shipwright.io -ojsonpath=' {.items[*].spec.nodeSelector}'
150+ assert_success
113151 assert_output --partial ' "kubernetes.io/hostname":"node-1"'
114- }
152+ }
153+
154+ @test " shp build run --scheduler-name" {
155+ # generate random names for our build
156+ build_name=$( random_name)
157+
158+ # create a Build with node selector
159+ run shp build create ${build_name} --source-git-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image
160+ assert_success
161+
162+ # ensure that the build was successfully created
163+ assert_output --partial " Created build \" ${build_name} \" "
164+
165+ # get the build object
166+ run kubectl get builds.shipwright.io/${build_name}
167+ assert_success
168+
169+ run shp build run ${build_name} --scheduler-name=${scheduler_name}
170+
171+ # get the jsonpath of BuildRun object .spec.schedulerName
172+ run kubectl get buildruns.shipwright.io -l build.shipwright.io/name=${build_name} -ojsonpath=' {.items[*].spec.schedulerName}'
173+ assert_success
174+ assert_output --partial " ${scheduler_name} "
175+ }
0 commit comments