Skip to content

Commit 779c3a4

Browse files
CSPL-3584: Split run-tests.sh into multiple files (#1507)
* split run-tests.sh into multiple files * trigger integration tests on branch * use scriptdir to run sh files * remove trigger int test workflow * test azure, gcp, and namespace scoped workflows * cleanup workflows
1 parent 618cc11 commit 779c3a4

File tree

5 files changed

+301
-236
lines changed

5 files changed

+301
-236
lines changed

test/deploy-operator.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
scriptdir=$(dirname "$0")
4+
topdir=${scriptdir}/..
5+
6+
source ${scriptdir}/env.sh
7+
8+
# Check if exactly 2 arguments are supplied
9+
if [ "$#" -ne 2 ]; then
10+
echo "Error: Exactly 2 arguments are required."
11+
echo "Usage: $0 <PRIVATE_SPLUNK_OPERATOR_IMAGE> <PRIVATE_SPLUNK_ENTERPRISE_IMAGE>"
12+
exit 1
13+
fi
14+
15+
# Assign arguments to variables
16+
PRIVATE_SPLUNK_OPERATOR_IMAGE="$1"
17+
PRIVATE_SPLUNK_ENTERPRISE_IMAGE="$2"
18+
19+
if [ "${DEPLOYMENT_TYPE}" == "helm" ]; then
20+
echo "Installing Splunk Operator using Helm charts"
21+
helm uninstall splunk-operator -n splunk-operator
22+
if [ "${CLUSTER_WIDE}" != "true" ]; then
23+
helm install splunk-operator --create-namespace --namespace splunk-operator --set splunkOperator.clusterWideAccess=false --set splunkOperator.image.repository=${PRIVATE_SPLUNK_OPERATOR_IMAGE} --set image.repository=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} helm-chart/splunk-operator
24+
else
25+
helm install splunk-operator --create-namespace --namespace splunk-operator --set splunkOperator.image.repository=${PRIVATE_SPLUNK_OPERATOR_IMAGE} --set image.repository=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} helm-chart/splunk-operator
26+
fi
27+
elif [ "${CLUSTER_WIDE}" != "true" ]; then
28+
# Install the CRDs
29+
echo "Installing enterprise CRDs..."
30+
make kustomize
31+
make uninstall
32+
bin/kustomize build config/crd | kubectl create -f -
33+
else
34+
echo "Installing enterprise operator from ${PRIVATE_SPLUNK_OPERATOR_IMAGE} using enterprise image from ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}..."
35+
make deploy IMG=${PRIVATE_SPLUNK_OPERATOR_IMAGE} SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} WATCH_NAMESPACE="" ENVIRONMENT=debug
36+
fi
37+
38+
if [ $? -ne 0 ]; then
39+
echo "Unable to install the operator. Exiting..."
40+
kubectl describe pod -n splunk-operator
41+
exit 1
42+
fi
43+
44+
echo "Dumping operator config here..."
45+
kubectl describe deployment splunk-operator-controller-manager -n splunk-operator
46+
47+
48+
if [ "${CLUSTER_WIDE}" == "true" ]; then
49+
echo "wait for operator pod to be ready..."
50+
# sleep before checking for deployment, in slow clusters deployment call may not even started
51+
# in those cases, kubectl will fail with error: no matching resources found
52+
sleep 2
53+
kubectl wait --for=condition=ready pod -l control-plane=controller-manager --timeout=600s -n splunk-operator
54+
if [ $? -ne 0 ]; then
55+
echo "kubectl get pods -n kube-system ---"
56+
kubectl get pods -n kube-system
57+
echo "kubectl get deployement ebs-csi-controller -n kube-system ---"
58+
kubectl get deployement ebs-csi-controller -n kube-system
59+
echo "kubectl describe pvc -n splunk-operator ---"
60+
kubectl describe pvc -n splunk-operator
61+
echo "kubectl describe pv ---"
62+
kubectl describe pv
63+
echo "kubectl describe pod -n splunk-operator ---"
64+
kubectl describe pod -n splunk-operator
65+
echo "Operator installation not ready..."
66+
exit 1
67+
fi
68+
fi
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
scriptdir=$(dirname "$0")
4+
topdir=${scriptdir}/..
5+
6+
source ${scriptdir}/env.sh
7+
8+
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${SPLUNK_ENTERPRISE_IMAGE}
9+
10+
# if we are using private registry, we need to pull, tag and push images to it
11+
if [ -n "${PRIVATE_REGISTRY}" ]; then
12+
13+
# CSPL-2920: ARM64 support
14+
if [ "$ARM64" != "true" ]; then
15+
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_ENTERPRISE_IMAGE}
16+
fi
17+
# Always attempt to pull splunk enterprise image
18+
echo "check if image exists, docker manifest inspect $PRIVATE_SPLUNK_ENTERPRISE_IMAGE"
19+
if docker manifest inspect "$PRIVATE_SPLUNK_ENTERPRISE_IMAGE" > /dev/null 2>&1; then
20+
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE exists on the remote repository."
21+
docker pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
22+
if [ $? -ne 0 ]; then
23+
echo "Unable to pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
24+
exit 1
25+
fi
26+
else
27+
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE does not exist on the remote repository."
28+
docker pull ${SPLUNK_ENTERPRISE_IMAGE}
29+
if [ $? -ne 0 ]; then
30+
echo "Unable to pull ${SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
31+
exit 1
32+
fi
33+
docker tag ${SPLUNK_ENTERPRISE_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
34+
docker push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
35+
if [ $? -ne 0 ]; then
36+
echo "Unable to push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
37+
exit 1
38+
fi
39+
fi
40+
41+
# Output
42+
echo "Docker images"
43+
docker images
44+
fi
45+
46+
# Return the value of PRIVATE_SPLUNK_ENTERPRISE_IMAGE
47+
echo "${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
scriptdir=$(dirname "$0")
4+
topdir=${scriptdir}/..
5+
6+
source ${scriptdir}/env.sh
7+
8+
PRIVATE_SPLUNK_OPERATOR_IMAGE=${SPLUNK_OPERATOR_IMAGE}
9+
10+
# if we are using private registry, we need to pull, tag and push images to it
11+
if [ -n "${PRIVATE_REGISTRY}" ]; then
12+
echo "Using private registry at ${PRIVATE_REGISTRY}"
13+
14+
PRIVATE_SPLUNK_OPERATOR_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_OPERATOR_IMAGE}
15+
echo "Checking to see if image exists, docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}"
16+
# Don't pull splunk operator if exists locally since we maybe building it locally
17+
if [ -z $(docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}) ]; then
18+
echo "Doesn't exist, pulling ${PRIVATE_SPLUNK_OPERATOR_IMAGE}..."
19+
docker pull ${PRIVATE_SPLUNK_OPERATOR_IMAGE}
20+
if [ $? -ne 0 ]; then
21+
echo "Unable to pull ${SPLUNK_OPERATOR_IMAGE}. Exiting..."
22+
exit 1
23+
fi
24+
fi
25+
26+
# Output
27+
echo "Docker images"
28+
docker images
29+
fi
30+
31+
# Return the value of PRIVATE_SPLUNK_OPERATOR_IMAGE
32+
echo "${PRIVATE_SPLUNK_OPERATOR_IMAGE}"

test/run-tests.sh

Lines changed: 4 additions & 236 deletions
Original file line numberDiff line numberDiff line change
@@ -5,239 +5,7 @@ topdir=${scriptdir}/..
55

66
source ${scriptdir}/env.sh
77

8-
PRIVATE_SPLUNK_OPERATOR_IMAGE=${SPLUNK_OPERATOR_IMAGE}
9-
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${SPLUNK_ENTERPRISE_IMAGE}
10-
11-
rc=$(which go)
12-
if [ -z "$rc" ]; then
13-
echo "go is not installed or in the PATH. Exiting..."
14-
exit 1
15-
fi
16-
17-
# if we are using private registry, we need to pull, tag and push images to it
18-
if [ -n "${PRIVATE_REGISTRY}" ]; then
19-
echo "Using private registry at ${PRIVATE_REGISTRY}"
20-
21-
PRIVATE_SPLUNK_OPERATOR_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_OPERATOR_IMAGE}
22-
# CSPL-2920: ARM64 support
23-
if [ "$ARM64" != "true" ]; then
24-
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_ENTERPRISE_IMAGE}
25-
fi
26-
echo "Checking to see if image exists, docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}"
27-
# Don't pull splunk operator if exists locally since we maybe building it locally
28-
if [ -z $(docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}) ]; then
29-
echo "Doesn't exist, pulling ${PRIVATE_SPLUNK_OPERATOR_IMAGE}..."
30-
docker pull ${PRIVATE_SPLUNK_OPERATOR_IMAGE}
31-
if [ $? -ne 0 ]; then
32-
echo "Unable to pull ${SPLUNK_OPERATOR_IMAGE}. Exiting..."
33-
exit 1
34-
fi
35-
fi
36-
37-
# Always attempt to pull splunk enterprise image
38-
echo "check if image exists, docker manifest inspect $PRIVATE_SPLUNK_ENTERPRISE_IMAGE"
39-
if docker manifest inspect "$PRIVATE_SPLUNK_ENTERPRISE_IMAGE" > /dev/null 2>&1; then
40-
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE exists on the remote repository."
41-
docker pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
42-
if [ $? -ne 0 ]; then
43-
echo "Unable to pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
44-
exit 1
45-
fi
46-
else
47-
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE does not exist on the remote repository."
48-
docker pull ${SPLUNK_ENTERPRISE_IMAGE}
49-
if [ $? -ne 0 ]; then
50-
echo "Unable to pull ${SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
51-
exit 1
52-
fi
53-
docker tag ${SPLUNK_ENTERPRISE_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
54-
docker push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
55-
if [ $? -ne 0 ]; then
56-
echo "Unable to push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
57-
exit 1
58-
fi
59-
fi
60-
61-
# Output
62-
echo "Docker images"
63-
docker images
64-
fi
65-
66-
if [ "${DEPLOYMENT_TYPE}" == "helm" ]; then
67-
echo "Installing Splunk Operator using Helm charts"
68-
helm uninstall splunk-operator -n splunk-operator
69-
if [ "${CLUSTER_WIDE}" != "true" ]; then
70-
helm install splunk-operator --create-namespace --namespace splunk-operator --set splunkOperator.clusterWideAccess=false --set splunkOperator.image.repository=${PRIVATE_SPLUNK_OPERATOR_IMAGE} --set image.repository=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} helm-chart/splunk-operator
71-
else
72-
helm install splunk-operator --create-namespace --namespace splunk-operator --set splunkOperator.image.repository=${PRIVATE_SPLUNK_OPERATOR_IMAGE} --set image.repository=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} helm-chart/splunk-operator
73-
fi
74-
elif [ "${CLUSTER_WIDE}" != "true" ]; then
75-
# Install the CRDs
76-
echo "Installing enterprise CRDs..."
77-
make kustomize
78-
make uninstall
79-
bin/kustomize build config/crd | kubectl create -f -
80-
else
81-
echo "Installing enterprise operator from ${PRIVATE_SPLUNK_OPERATOR_IMAGE} using enterprise image from ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}..."
82-
make deploy IMG=${PRIVATE_SPLUNK_OPERATOR_IMAGE} SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} WATCH_NAMESPACE="" ENVIRONMENT=debug
83-
fi
84-
85-
if [ $? -ne 0 ]; then
86-
echo "Unable to install the operator. Exiting..."
87-
kubectl describe pod -n splunk-operator
88-
exit 1
89-
fi
90-
91-
echo "Dumping operator config here..."
92-
kubectl describe deployment splunk-operator-controller-manager -n splunk-operator
93-
94-
95-
if [ "${CLUSTER_WIDE}" == "true" ]; then
96-
echo "wait for operator pod to be ready..."
97-
# sleep before checking for deployment, in slow clusters deployment call may not even started
98-
# in those cases, kubectl will fail with error: no matching resources found
99-
sleep 2
100-
kubectl wait --for=condition=ready pod -l control-plane=controller-manager --timeout=600s -n splunk-operator
101-
if [ $? -ne 0 ]; then
102-
echo "kubectl get pods -n kube-system ---"
103-
kubectl get pods -n kube-system
104-
echo "kubectl get deployement ebs-csi-controller -n kube-system ---"
105-
kubectl get deployement ebs-csi-controller -n kube-system
106-
echo "kubectl describe pvc -n splunk-operator ---"
107-
kubectl describe pvc -n splunk-operator
108-
echo "kubectl describe pv ---"
109-
kubectl describe pv
110-
echo "kubectl describe pod -n splunk-operator ---"
111-
kubectl describe pod -n splunk-operator
112-
echo "Operator installation not ready..."
113-
exit 1
114-
fi
115-
fi
116-
117-
rc=$(which ginkgo)
118-
if [ -z "$rc" ]; then
119-
echo "ginkgo is not installed or in the PATH. Installing..."
120-
go get github.com/onsi/ginkgo/ginkgo/v2
121-
go get github.com/onsi/gomega/...
122-
123-
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest
124-
fi
125-
126-
127-
echo "Running test using number of nodes: ${NUM_NODES}"
128-
echo "Running test using these images: ${PRIVATE_SPLUNK_OPERATOR_IMAGE} and ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}..."
129-
130-
131-
# Check if test focus is set
132-
if [[ -z "${TEST_FOCUS}" ]]; then
133-
TEST_TO_RUN="${TEST_REGEX}"
134-
echo "Test focus not set running smoke test by default :: ${TEST_TO_RUN}"
135-
else
136-
TEST_TO_RUN="${TEST_FOCUS}"
137-
echo "Running following test :: ${TEST_TO_RUN}"
138-
fi
139-
140-
# Set variables
141-
export CLUSTER_PROVIDER="${CLUSTER_PROVIDER}"
142-
case ${CLUSTER_PROVIDER} in
143-
"eks")
144-
if [[ -z "${ENTERPRISE_LICENSE_LOCATION}" ]]; then
145-
echo "License path not set. Changing to default"
146-
export ENTERPRISE_LICENSE_LOCATION="${ENTERPRISE_LICENSE_S3_PATH}"
147-
fi
148-
149-
if [[ -z "${TEST_BUCKET}" ]]; then
150-
echo "Data bucket not set. Changing to default"
151-
export TEST_BUCKET="${TEST_S3_BUCKET}"
152-
fi
153-
154-
if [[ -z "${TEST_INDEXES_S3_BUCKET}" ]]; then
155-
echo "Test bucket not set. Changing to default"
156-
export TEST_INDEXES_S3_BUCKET="${INDEXES_S3_BUCKET}"
157-
fi
158-
159-
if [[ -z "${S3_REGION}" ]]; then
160-
echo "S3 Region not set. Changing to default"
161-
export S3_REGION="${AWS_S3_REGION}"
162-
fi
163-
;;
164-
"azure")
165-
if [[ -z "${ENTERPRISE_LICENSE_LOCATION}" ]]; then
166-
echo "License path not set. Changing to default"
167-
export ENTERPRISE_LICENSE_LOCATION="${AZURE_ENTERPRISE_LICENSE_PATH}"
168-
fi
169-
170-
if [[ -z "${TEST_CONTAINER}" ]]; then
171-
echo "Data container not set. Changing to default"
172-
export TEST_CONTAINER="${AZURE_TEST_CONTAINER}"
173-
fi
174-
175-
if [[ -z "${INDEXES_CONTAINER}" ]]; then
176-
echo "Test container not set. Changing to default"
177-
export INDEXES_CONTAINER="${AZURE_INDEXES_CONTAINER}"
178-
fi
179-
180-
if [[ -z "${REGION}" ]]; then
181-
echo "Azure Region not set. Changing to default"
182-
export REGION="${AZURE_REGION}"
183-
fi
184-
185-
if [[ -z "${STORAGE_ACCOUNT}" ]]; then
186-
echo "Azure Storage account not set. Changing to default"
187-
export STORAGE_ACCOUNT="${AZURE_STORAGE_ACCOUNT}"
188-
fi
189-
190-
if [[ -z "${STORAGE_ACCOUNT_KEY}" ]]; then
191-
echo "Azure Storage account key not set. Changing to default"
192-
export STORAGE_ACCOUNT_KEY="${AZURE_STORAGE_ACCOUNT_KEY}"
193-
fi
194-
;;
195-
"gcp")
196-
if [[ -z "${GCP_ENTERPRISE_LICENSE_LOCATION}" ]]; then
197-
echo "License path not set. Changing to default"
198-
export ENTERPRISE_LICENSE_LOCATION="${GCP_ENTERPRISE_LICENSE_LOCATION}"
199-
fi
200-
if [[ -z "${ENTERPRISE_LICENSE_LOCATION}" ]]; then
201-
echo "License path not set. Changing to default"
202-
export ENTERPRISE_LICENSE_LOCATION="${ENTERPRISE_LICENSE_S3_PATH}"
203-
fi
204-
205-
if [[ -z "${TEST_BUCKET}" ]]; then
206-
echo "Data bucket not set. Changing to default"
207-
export TEST_BUCKET="${TEST_S3_BUCKET}"
208-
fi
209-
210-
if [[ -z "${TEST_INDEXES_S3_BUCKET}" ]]; then
211-
echo "Test bucket not set. Changing to default"
212-
export TEST_INDEXES_S3_BUCKET="${INDEXES_S3_BUCKET}"
213-
fi
214-
215-
if [[ -z "${S3_REGION}" ]]; then
216-
echo "S3 Region not set. Changing to default"
217-
export S3_REGION="${AWS_S3_REGION}"
218-
fi
219-
;;
220-
esac
221-
222-
223-
if [[ -z "${CLUSTER_NODES}" ]]; then
224-
echo "Test Cluster Nodes Not Set in Environment Variables. Changing to env.sh value"
225-
export CLUSTER_NODES="${NUM_NODES}"
226-
fi
227-
if [[ -z "${TEST_TO_SKIP}" ]]; then
228-
echo "TEST_TO_SKIP not set. Changing to default"
229-
export TEST_TO_SKIP="${SKIP_REGEX}"
230-
fi
231-
232-
if [[ -z "${DEBUG}" ]]; then
233-
echo "DEBUG not set. Changing to default"
234-
export DEBUG="${DEBUG_RUN}"
235-
fi
236-
237-
238-
239-
echo "Skipping following test :: ${TEST_TO_SKIP}"
240-
241-
# Running only smoke test cases by default or value passed through TEST_FOCUS env variable. To run different test packages add/remove path from focus argument or TEST_FOCUS variable
242-
echo "ginkgo --junit-report=inttest.xml -vv --keep-going --trace -r --timeout=7h -nodes=${CLUSTER_NODES} --focus="${TEST_TO_RUN}" --skip="${TEST_TO_SKIP}" --output-interceptor-mode=none --cover ${topdir}/test/ -- -commit-hash=${COMMIT_HASH} -operator-image=${PRIVATE_SPLUNK_OPERATOR_IMAGE} -splunk-image=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} -cluster-wide=${CLUSTER_WIDE}"
243-
ginkgo --junit-report=inttest-junit.xml --output-dir=`pwd` -vv --keep-going --trace -r --timeout=7h -nodes=${CLUSTER_NODES} --focus="${TEST_TO_RUN}" --skip="${TEST_TO_SKIP}" --output-interceptor-mode=none --cover ${topdir}/test/ -- -commit-hash=${COMMIT_HASH} -operator-image=${PRIVATE_SPLUNK_OPERATOR_IMAGE} -splunk-image=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} -cluster-wide=${CLUSTER_WIDE}
8+
PRIVATE_SPLUNK_OPERATOR_IMAGE=$(bash ${scriptdir}/get-private-registry-operator.sh | tail -1)
9+
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=$(bash ${scriptdir}/get-private-registry-enterprise.sh | tail -1)
10+
bash ${scriptdir}/deploy-operator.sh ${PRIVATE_SPLUNK_OPERATOR_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
11+
bash ${scriptdir}/trigger-tests.sh ${PRIVATE_SPLUNK_OPERATOR_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}

0 commit comments

Comments
 (0)