Skip to content
68 changes: 68 additions & 0 deletions test/deploy-operator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

scriptdir=$(dirname "$0")
topdir=${scriptdir}/..

source ${scriptdir}/env.sh

# Check if exactly 2 arguments are supplied
if [ "$#" -ne 2 ]; then
echo "Error: Exactly 2 arguments are required."
echo "Usage: $0 <PRIVATE_SPLUNK_OPERATOR_IMAGE> <PRIVATE_SPLUNK_ENTERPRISE_IMAGE>"
exit 1
fi

# Assign arguments to variables
PRIVATE_SPLUNK_OPERATOR_IMAGE="$1"
PRIVATE_SPLUNK_ENTERPRISE_IMAGE="$2"

if [ "${DEPLOYMENT_TYPE}" == "helm" ]; then
echo "Installing Splunk Operator using Helm charts"
helm uninstall splunk-operator -n splunk-operator
if [ "${CLUSTER_WIDE}" != "true" ]; then
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
else
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
fi
elif [ "${CLUSTER_WIDE}" != "true" ]; then
# Install the CRDs
echo "Installing enterprise CRDs..."
make kustomize
make uninstall
bin/kustomize build config/crd | kubectl create -f -
else
echo "Installing enterprise operator from ${PRIVATE_SPLUNK_OPERATOR_IMAGE} using enterprise image from ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}..."
make deploy IMG=${PRIVATE_SPLUNK_OPERATOR_IMAGE} SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} WATCH_NAMESPACE="" ENVIRONMENT=debug
fi

if [ $? -ne 0 ]; then
echo "Unable to install the operator. Exiting..."
kubectl describe pod -n splunk-operator
exit 1
fi

echo "Dumping operator config here..."
kubectl describe deployment splunk-operator-controller-manager -n splunk-operator


if [ "${CLUSTER_WIDE}" == "true" ]; then
echo "wait for operator pod to be ready..."
# sleep before checking for deployment, in slow clusters deployment call may not even started
# in those cases, kubectl will fail with error: no matching resources found
sleep 2
kubectl wait --for=condition=ready pod -l control-plane=controller-manager --timeout=600s -n splunk-operator
if [ $? -ne 0 ]; then
echo "kubectl get pods -n kube-system ---"
kubectl get pods -n kube-system
echo "kubectl get deployement ebs-csi-controller -n kube-system ---"
kubectl get deployement ebs-csi-controller -n kube-system
echo "kubectl describe pvc -n splunk-operator ---"
kubectl describe pvc -n splunk-operator
echo "kubectl describe pv ---"
kubectl describe pv
echo "kubectl describe pod -n splunk-operator ---"
kubectl describe pod -n splunk-operator
echo "Operator installation not ready..."
exit 1
fi
fi
47 changes: 47 additions & 0 deletions test/get-private-registry-enterprise.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

scriptdir=$(dirname "$0")
topdir=${scriptdir}/..

source ${scriptdir}/env.sh

PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${SPLUNK_ENTERPRISE_IMAGE}

# if we are using private registry, we need to pull, tag and push images to it
if [ -n "${PRIVATE_REGISTRY}" ]; then

# CSPL-2920: ARM64 support
if [ "$ARM64" != "true" ]; then
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_ENTERPRISE_IMAGE}
fi
# Always attempt to pull splunk enterprise image
echo "check if image exists, docker manifest inspect $PRIVATE_SPLUNK_ENTERPRISE_IMAGE"
if docker manifest inspect "$PRIVATE_SPLUNK_ENTERPRISE_IMAGE" > /dev/null 2>&1; then
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE exists on the remote repository."
docker pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
exit 1
fi
else
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE does not exist on the remote repository."
docker pull ${SPLUNK_ENTERPRISE_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to pull ${SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
exit 1
fi
docker tag ${SPLUNK_ENTERPRISE_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
docker push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
exit 1
fi
fi

# Output
echo "Docker images"
docker images
fi

# Return the value of PRIVATE_SPLUNK_ENTERPRISE_IMAGE
echo "${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}"
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the operator script, ensure that all logging is directed to stderr so that the echoed image value is not obscured by extra output. This will make the 'tail -1' extraction in the calling script more reliable.

Copilot uses AI. Check for mistakes.
32 changes: 32 additions & 0 deletions test/get-private-registry-operator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

scriptdir=$(dirname "$0")
topdir=${scriptdir}/..

source ${scriptdir}/env.sh

PRIVATE_SPLUNK_OPERATOR_IMAGE=${SPLUNK_OPERATOR_IMAGE}

# if we are using private registry, we need to pull, tag and push images to it
if [ -n "${PRIVATE_REGISTRY}" ]; then
echo "Using private registry at ${PRIVATE_REGISTRY}"

PRIVATE_SPLUNK_OPERATOR_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_OPERATOR_IMAGE}
echo "Checking to see if image exists, docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}"
# Don't pull splunk operator if exists locally since we maybe building it locally
if [ -z $(docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}) ]; then
echo "Doesn't exist, pulling ${PRIVATE_SPLUNK_OPERATOR_IMAGE}..."
docker pull ${PRIVATE_SPLUNK_OPERATOR_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to pull ${SPLUNK_OPERATOR_IMAGE}. Exiting..."
exit 1
fi
fi

# Output
echo "Docker images"
docker images
fi

# Return the value of PRIVATE_SPLUNK_OPERATOR_IMAGE
echo "${PRIVATE_SPLUNK_OPERATOR_IMAGE}"
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the script outputs extra logging (e.g., 'Docker images'), the final echo might be mixed with those logs. Redirect log messages to stderr so that stdout contains only the intended value for callers.

Copilot uses AI. Check for mistakes.
240 changes: 4 additions & 236 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,239 +5,7 @@ topdir=${scriptdir}/..

source ${scriptdir}/env.sh

PRIVATE_SPLUNK_OPERATOR_IMAGE=${SPLUNK_OPERATOR_IMAGE}
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${SPLUNK_ENTERPRISE_IMAGE}

rc=$(which go)
if [ -z "$rc" ]; then
echo "go is not installed or in the PATH. Exiting..."
exit 1
fi

# if we are using private registry, we need to pull, tag and push images to it
if [ -n "${PRIVATE_REGISTRY}" ]; then
echo "Using private registry at ${PRIVATE_REGISTRY}"

PRIVATE_SPLUNK_OPERATOR_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_OPERATOR_IMAGE}
# CSPL-2920: ARM64 support
if [ "$ARM64" != "true" ]; then
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_REGISTRY}/${SPLUNK_ENTERPRISE_IMAGE}
fi
echo "Checking to see if image exists, docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}"
# Don't pull splunk operator if exists locally since we maybe building it locally
if [ -z $(docker images -q ${PRIVATE_SPLUNK_OPERATOR_IMAGE}) ]; then
echo "Doesn't exist, pulling ${PRIVATE_SPLUNK_OPERATOR_IMAGE}..."
docker pull ${PRIVATE_SPLUNK_OPERATOR_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to pull ${SPLUNK_OPERATOR_IMAGE}. Exiting..."
exit 1
fi
fi

# Always attempt to pull splunk enterprise image
echo "check if image exists, docker manifest inspect $PRIVATE_SPLUNK_ENTERPRISE_IMAGE"
if docker manifest inspect "$PRIVATE_SPLUNK_ENTERPRISE_IMAGE" > /dev/null 2>&1; then
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE exists on the remote repository."
docker pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to pull ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
exit 1
fi
else
echo "Image $PRIVATE_SPLUNK_ENTERPRISE_IMAGE does not exist on the remote repository."
docker pull ${SPLUNK_ENTERPRISE_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to pull ${SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
exit 1
fi
docker tag ${SPLUNK_ENTERPRISE_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
docker push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
if [ $? -ne 0 ]; then
echo "Unable to push ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}. Exiting..."
exit 1
fi
fi

# Output
echo "Docker images"
docker images
fi

if [ "${DEPLOYMENT_TYPE}" == "helm" ]; then
echo "Installing Splunk Operator using Helm charts"
helm uninstall splunk-operator -n splunk-operator
if [ "${CLUSTER_WIDE}" != "true" ]; then
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
else
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
fi
elif [ "${CLUSTER_WIDE}" != "true" ]; then
# Install the CRDs
echo "Installing enterprise CRDs..."
make kustomize
make uninstall
bin/kustomize build config/crd | kubectl create -f -
else
echo "Installing enterprise operator from ${PRIVATE_SPLUNK_OPERATOR_IMAGE} using enterprise image from ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}..."
make deploy IMG=${PRIVATE_SPLUNK_OPERATOR_IMAGE} SPLUNK_ENTERPRISE_IMAGE=${PRIVATE_SPLUNK_ENTERPRISE_IMAGE} WATCH_NAMESPACE="" ENVIRONMENT=debug
fi

if [ $? -ne 0 ]; then
echo "Unable to install the operator. Exiting..."
kubectl describe pod -n splunk-operator
exit 1
fi

echo "Dumping operator config here..."
kubectl describe deployment splunk-operator-controller-manager -n splunk-operator


if [ "${CLUSTER_WIDE}" == "true" ]; then
echo "wait for operator pod to be ready..."
# sleep before checking for deployment, in slow clusters deployment call may not even started
# in those cases, kubectl will fail with error: no matching resources found
sleep 2
kubectl wait --for=condition=ready pod -l control-plane=controller-manager --timeout=600s -n splunk-operator
if [ $? -ne 0 ]; then
echo "kubectl get pods -n kube-system ---"
kubectl get pods -n kube-system
echo "kubectl get deployement ebs-csi-controller -n kube-system ---"
kubectl get deployement ebs-csi-controller -n kube-system
echo "kubectl describe pvc -n splunk-operator ---"
kubectl describe pvc -n splunk-operator
echo "kubectl describe pv ---"
kubectl describe pv
echo "kubectl describe pod -n splunk-operator ---"
kubectl describe pod -n splunk-operator
echo "Operator installation not ready..."
exit 1
fi
fi

rc=$(which ginkgo)
if [ -z "$rc" ]; then
echo "ginkgo is not installed or in the PATH. Installing..."
go get github.com/onsi/ginkgo/ginkgo/v2
go get github.com/onsi/gomega/...

go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest
fi


echo "Running test using number of nodes: ${NUM_NODES}"
echo "Running test using these images: ${PRIVATE_SPLUNK_OPERATOR_IMAGE} and ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}..."


# Check if test focus is set
if [[ -z "${TEST_FOCUS}" ]]; then
TEST_TO_RUN="${TEST_REGEX}"
echo "Test focus not set running smoke test by default :: ${TEST_TO_RUN}"
else
TEST_TO_RUN="${TEST_FOCUS}"
echo "Running following test :: ${TEST_TO_RUN}"
fi

# Set variables
export CLUSTER_PROVIDER="${CLUSTER_PROVIDER}"
case ${CLUSTER_PROVIDER} in
"eks")
if [[ -z "${ENTERPRISE_LICENSE_LOCATION}" ]]; then
echo "License path not set. Changing to default"
export ENTERPRISE_LICENSE_LOCATION="${ENTERPRISE_LICENSE_S3_PATH}"
fi

if [[ -z "${TEST_BUCKET}" ]]; then
echo "Data bucket not set. Changing to default"
export TEST_BUCKET="${TEST_S3_BUCKET}"
fi

if [[ -z "${TEST_INDEXES_S3_BUCKET}" ]]; then
echo "Test bucket not set. Changing to default"
export TEST_INDEXES_S3_BUCKET="${INDEXES_S3_BUCKET}"
fi

if [[ -z "${S3_REGION}" ]]; then
echo "S3 Region not set. Changing to default"
export S3_REGION="${AWS_S3_REGION}"
fi
;;
"azure")
if [[ -z "${ENTERPRISE_LICENSE_LOCATION}" ]]; then
echo "License path not set. Changing to default"
export ENTERPRISE_LICENSE_LOCATION="${AZURE_ENTERPRISE_LICENSE_PATH}"
fi

if [[ -z "${TEST_CONTAINER}" ]]; then
echo "Data container not set. Changing to default"
export TEST_CONTAINER="${AZURE_TEST_CONTAINER}"
fi

if [[ -z "${INDEXES_CONTAINER}" ]]; then
echo "Test container not set. Changing to default"
export INDEXES_CONTAINER="${AZURE_INDEXES_CONTAINER}"
fi

if [[ -z "${REGION}" ]]; then
echo "Azure Region not set. Changing to default"
export REGION="${AZURE_REGION}"
fi

if [[ -z "${STORAGE_ACCOUNT}" ]]; then
echo "Azure Storage account not set. Changing to default"
export STORAGE_ACCOUNT="${AZURE_STORAGE_ACCOUNT}"
fi

if [[ -z "${STORAGE_ACCOUNT_KEY}" ]]; then
echo "Azure Storage account key not set. Changing to default"
export STORAGE_ACCOUNT_KEY="${AZURE_STORAGE_ACCOUNT_KEY}"
fi
;;
"gcp")
if [[ -z "${GCP_ENTERPRISE_LICENSE_LOCATION}" ]]; then
echo "License path not set. Changing to default"
export ENTERPRISE_LICENSE_LOCATION="${GCP_ENTERPRISE_LICENSE_LOCATION}"
fi
if [[ -z "${ENTERPRISE_LICENSE_LOCATION}" ]]; then
echo "License path not set. Changing to default"
export ENTERPRISE_LICENSE_LOCATION="${ENTERPRISE_LICENSE_S3_PATH}"
fi

if [[ -z "${TEST_BUCKET}" ]]; then
echo "Data bucket not set. Changing to default"
export TEST_BUCKET="${TEST_S3_BUCKET}"
fi

if [[ -z "${TEST_INDEXES_S3_BUCKET}" ]]; then
echo "Test bucket not set. Changing to default"
export TEST_INDEXES_S3_BUCKET="${INDEXES_S3_BUCKET}"
fi

if [[ -z "${S3_REGION}" ]]; then
echo "S3 Region not set. Changing to default"
export S3_REGION="${AWS_S3_REGION}"
fi
;;
esac


if [[ -z "${CLUSTER_NODES}" ]]; then
echo "Test Cluster Nodes Not Set in Environment Variables. Changing to env.sh value"
export CLUSTER_NODES="${NUM_NODES}"
fi
if [[ -z "${TEST_TO_SKIP}" ]]; then
echo "TEST_TO_SKIP not set. Changing to default"
export TEST_TO_SKIP="${SKIP_REGEX}"
fi

if [[ -z "${DEBUG}" ]]; then
echo "DEBUG not set. Changing to default"
export DEBUG="${DEBUG_RUN}"
fi



echo "Skipping following test :: ${TEST_TO_SKIP}"

# 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
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}"
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}
PRIVATE_SPLUNK_OPERATOR_IMAGE=$(bash ${scriptdir}/get-private-registry-operator.sh | tail -1)
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'tail -1' to extract the final output of the get-private-registry-operator.sh script can be brittle if extra logging output is printed. Consider modifying the script to send log messages to stderr and reserve stdout for the image value only.

Copilot uses AI. Check for mistakes.
PRIVATE_SPLUNK_ENTERPRISE_IMAGE=$(bash ${scriptdir}/get-private-registry-enterprise.sh | tail -1)
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'tail -1' to capture the final output from get-private-registry-enterprise.sh may lead to errors if additional output is produced. Consider isolating the image output to stdout (logging to stderr) to ensure reliable retrieval.

Copilot uses AI. Check for mistakes.
bash ${scriptdir}/deploy-operator.sh ${PRIVATE_SPLUNK_OPERATOR_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
bash ${scriptdir}/trigger-tests.sh ${PRIVATE_SPLUNK_OPERATOR_IMAGE} ${PRIVATE_SPLUNK_ENTERPRISE_IMAGE}
Loading
Loading