1
+ #! /usr/bin/env bats
2
+
3
+ source test/e2e/helpers.sh
4
+
5
+ setup () {
6
+ load ' bats/support/load'
7
+ load ' bats/assert/load'
8
+ load ' bats/file/load'
9
+ }
10
+
11
+ teardown () {
12
+ run kubectl delete builds.shipwright.io --all
13
+ run kubectl delete buildruns.shipwright.io --all
14
+ }
15
+
16
+ @test " shp build node selector single label" {
17
+ # generate random names for our build
18
+ build_name=$( random_name)
19
+
20
+ # create a Build with node selector
21
+ run shp build create ${build_name} --source-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image --node=" kubernetes.io/hostname=node-1"
22
+ assert_success
23
+
24
+ # ensure that the build was successfully created
25
+ assert_output --partial " Created build \" ${build_name} \" "
26
+
27
+ # get the jsonpath of Build object .spec.nodeSelector
28
+ run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.nodeSelector}"
29
+ assert_success
30
+
31
+ assert_output ' {"kubernetes.io/hostname":"node-1"}'
32
+ }
33
+
34
+ @test " shp build node selector multiple labels" {
35
+ # generate random names for our build
36
+ build_name=$( random_name)
37
+
38
+ # create a Build with node selector
39
+ run shp build create ${build_name} --source-url=https://github.com/shipwright-io/sample-go --output-image=my-fake-image --node=" kubernetes.io/hostname=node-1" --node=" kubernetes.io/os=linux"
40
+ assert_success
41
+
42
+ # ensure that the build was successfully created
43
+ assert_output --partial " Created build \" ${build_name} \" "
44
+
45
+ # get the jsonpath of Build object .spec.nodeSelector
46
+ run kubectl get builds.shipwright.io/${build_name} -ojsonpath=" {.spec.nodeSelector}"
47
+ assert_success
48
+
49
+ assert_output --partial ' "kubernetes.io/hostname":"node-1"'
50
+ assert_output --partial ' "kubernetes.io/os":"linux"'
51
+ }
52
+
53
+ @test " shp buildrun node selector single label" {
54
+ # generate random names for our buildrun
55
+ buildrun_name=$( random_name)
56
+ build_name=$( random_name)
57
+
58
+ # create a Build with node selector
59
+ run shp buildrun create ${buildrun_name} --buildref-name=${build_name} --node=" kubernetes.io/hostname=node-1"
60
+ assert_success
61
+
62
+ # ensure that the build was successfully created
63
+ assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
64
+
65
+ # get the jsonpath of Build object .spec.nodeSelector
66
+ run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.nodeSelector}"
67
+ assert_success
68
+
69
+ assert_output ' {"kubernetes.io/hostname":"node-1"}'
70
+ }
71
+
72
+ @test " shp buildrun node selector multiple labels" {
73
+ # generate random names for our buildrun
74
+ buildrun_name=$( random_name)
75
+ build_name=$( random_name)
76
+
77
+ # create a Build with node selector
78
+ run shp buildrun create ${buildrun_name} --buildref-name=${build_name} --node=" kubernetes.io/hostname=node-1" --node=" kubernetes.io/os=linux"
79
+ assert_success
80
+
81
+ # ensure that the build was successfully created
82
+ assert_output --partial " BuildRun created \" ${buildrun_name} \" for Build \" ${build_name} \" "
83
+
84
+ # get the jsonpath of Build object .spec.nodeSelector
85
+ run kubectl get buildruns.shipwright.io/${buildrun_name} -ojsonpath=" {.spec.nodeSelector}"
86
+ assert_success
87
+
88
+ assert_output --partial ' "kubernetes.io/hostname":"node-1"'
89
+ assert_output --partial ' "kubernetes.io/os":"linux"'
90
+ }
0 commit comments