File tree Expand file tree Collapse file tree 3 files changed +51
-31
lines changed Expand file tree Collapse file tree 3 files changed +51
-31
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
1
3
function listPkgs() {
2
4
go list ./commands/... ./pkg/... ./test/... | grep -v generated
3
5
}
@@ -13,3 +15,34 @@ function listFiles() {
13
15
# pipeline is much faster than for loop
14
16
listPkgs | xargs -I {} find " ${GOPATH} /src/{}" -name ' *.go' | grep -v generated
15
17
}
18
+
19
+ # ===================================================================
20
+ # FUNCTION trap_add ()
21
+ #
22
+ # Purpose: prepends a command to a trap
23
+ #
24
+ # - 1st arg: code to add
25
+ # - remaining args: names of traps to modify
26
+ #
27
+ # Example: trap_add 'echo "in trap DEBUG"' DEBUG
28
+ #
29
+ # See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
30
+ # ===================================================================
31
+ function trap_add() {
32
+ trap_add_cmd=$1 ; shift || fatal " ${FUNCNAME} usage error"
33
+ new_cmd=
34
+ for trap_add_name in " $@ " ; do
35
+ # Grab the currently defined trap commands for this trap
36
+ existing_cmd=` trap -p " ${trap_add_name} " | awk -F" '" ' {print $2}' `
37
+
38
+ # Define default command
39
+ [ -z " ${existing_cmd} " ] && existing_cmd=" echo exiting @ ` date` "
40
+
41
+ # Generate the new command
42
+ new_cmd=" ${trap_add_cmd} ;${existing_cmd} "
43
+
44
+ # Assign the test
45
+ trap " ${new_cmd} " " ${trap_add_name} " || \
46
+ fatal " unable to add to trap ${trap_add_name} "
47
+ done
48
+ }
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- # ===================================================================
4
- # FUNCTION trap_add ()
5
- #
6
- # Purpose: prepends a command to a trap
7
- #
8
- # - 1st arg: code to add
9
- # - remaining args: names of traps to modify
10
- #
11
- # Example: trap_add 'echo "in trap DEBUG"' DEBUG
12
- #
13
- # See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
14
- # ===================================================================
15
- trap_add () {
16
- trap_add_cmd=$1 ; shift || fatal " ${FUNCNAME} usage error"
17
- new_cmd=
18
- for trap_add_name in " $@ " ; do
19
- # Grab the currently defined trap commands for this trap
20
- existing_cmd=` trap -p " ${trap_add_name} " | awk -F" '" ' {print $2}' `
21
-
22
- # Define default command
23
- [ -z " ${existing_cmd} " ] && existing_cmd=" echo exiting @ ` date` "
24
-
25
- # Generate the new command
26
- new_cmd=" ${trap_add_cmd} ;${existing_cmd} "
27
-
28
- # Assign the test
29
- trap " ${new_cmd} " " ${trap_add_name} " || \
30
- fatal " unable to add to trap ${trap_add_name} "
31
- done
32
- }
3
+ source hack/lib/test_lib.sh
33
4
34
5
DEST_IMAGE=" quay.io/example/memcached-operator:v0.0.2"
35
6
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
+ source hack/lib/test_lib.sh
3
+
2
4
set -ex
3
5
4
- cd test/test-framework
6
+ pushd test/test-framework
5
7
# test framework with defaults
6
8
operator-sdk test local .
7
9
# test operator-sdk test flags
8
10
operator-sdk test local . --global-manifest deploy/crds/cache_v1alpha1_memcached_crd.yaml --namespaced-manifest deploy/namespace-init.yaml --go-test-flags " -parallel 1" --kubeconfig $HOME /.kube/config
9
11
# test operator-sdk test local single namespace mode
10
12
kubectl create namespace test-memcached
13
+ # we use the test-memcached namespace for all future tests, so we only need to set this trap once
14
+ trap_add ' kubectl delete namespace test-memcached' EXIT
11
15
operator-sdk test local . --namespace=test-memcached
12
16
kubectl delete namespace test-memcached
17
+ # test operator in no-setup mode
18
+ kubectl create namespace test-memcached
19
+ kubectl create -f deploy/crds/cache_v1alpha1_memcached_crd.yaml
20
+ # this runs after the popd at the end, so it needs the path from the project root
21
+ trap_add ' kubectl delete -f test/test-framework/deploy/crds/cache_v1alpha1_memcached_crd.yaml' EXIT
22
+ kubectl create -f deploy/service_account.yaml --namespace test-memcached
23
+ kubectl create -f deploy/role.yaml --namespace test-memcached
24
+ kubectl create -f deploy/role_binding.yaml --namespace test-memcached
25
+ kubectl create -f deploy/operator.yaml --namespace test-memcached
26
+ operator-sdk test local . --namespace=test-memcached --no-setup
27
+ kubectl delete namespace test-memcached
28
+ popd
You can’t perform that action at this time.
0 commit comments