Skip to content

Change health check and prom internal metrics ports to a unique value #3816

Change health check and prom internal metrics ports to a unique value

Change health check and prom internal metrics ports to a unique value #3816

name: Splunk Platform Functional Test
on:
pull_request:
env:
GO_VERSION: 1.24.1
# Make sure to exit early if cache segment download times out after 2 minutes.
# We limit cache download as a whole to 5 minutes.
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
jobs:
get-test-matrix:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: get matrix
id: test_matrix
run: |
echo "Getting test matrix"
matrix=`cat ci-matrix.json | jq '.functional_test' | jq -r 'tostring' | tr -d '\n'`
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.test_matrix.outputs.matrix }}
functional-test:
name: K8s ${{ matrix.k8s-minikube-version }} ${{ matrix.container_runtime }}, Splunk ${{ matrix.splunk_version }}
runs-on: ubuntu-latest
needs: get-test-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.get-test-matrix.outputs.matrix) }}
env:
CI_SPLUNK_PORT: 8089
CI_SPLUNK_USERNAME: admin
CI_SPLUNK_HEC_TOKEN: "00000000-0000-0000-0000-0000000000000"
CI_SPLUNK_PASSWORD: helloworld
CI_INDEX_EVENTS: ci_events
CI_INDEX_METRICS: ci_metrics
CONTAINER_RUNTIME: ${{ matrix.container_runtime }}
KUBERNETES_VERSION: ${{ matrix.k8s-minikube-version }}
SPLUNK_VERSION: ${{ matrix.splunk_version }}
MINIKUBE_VERSION: latest
KUBECONFIG: /tmp/kube-config-splunk-otel-collector-chart-functional-testing
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
# # Leave this here for debugging
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Setup Minikube
run: |
# Install Kubectl
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
mkdir -p /tmp/kube-config-splunk-otel-collector-chart-splunk-integration-testing
# Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/
sudo sysctl fs.protected_regular=0
# Start Minikube and Wait
minikube start --container-runtime=${CONTAINER_RUNTIME} --cpus 2 --memory 4096 --kubernetes-version=${KUBERNETES_VERSION} --no-vtx-check
export JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1;
done
echo "Kubernetes $(kubectl version --short | grep -E 'Client|Server')" && echo "Container Runtime for Node: $(kubectl get node -o=jsonpath='{.items[0].metadata.name}'): $(kubectl get node -o=jsonpath='{.items[0].status.nodeInfo.containerRuntimeVersion}')"
- name: Install Splunk
run: |
# Wait until default service account is created
until kubectl -n default get serviceaccount default -o name; do
sleep 1;
done
# set splunk version, hec_token, splunk password in k8s-splunk.yaml file
sed -i "s/splunk:9.3.0/splunk:${SPLUNK_VERSION}/g" ci_scripts/k8s-splunk.yml
sed -i "s/value: helloworld/value: ${CI_SPLUNK_PASSWORD}/g" ci_scripts/k8s-splunk.yml
sed -i "s/value: 00000000-0000-0000-0000-0000000000000/value: ${CI_SPLUNK_HEC_TOKEN}/g" ci_scripts/k8s-splunk.yml
cat ci_scripts/k8s-splunk.yml
# Install Splunk on minikube
kubectl apply -f ci_scripts/k8s-splunk.yml
# Wait until splunk is ready
until kubectl logs splunk --tail=2 | grep -q 'Ansible playbook complete'; do
sleep 1;
done
- name: Deploy splunk-otel-collector chart
run: |
make dep-update
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
ci_scripts/deploy_collector.sh
- name: Deploy log generator
run: |
kubectl apply -f test/test_setup.yaml
sleep 60
- name: Run Splunk Integration Tests
run: |
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
cd test
go test -v -tags splunk_integration
- name: Print splunk-otel-collector logs
if: always()
run: |
# Echo logs for the collector (agent,cluster-receiver,gateway) for visibility
pods=$(kubectl get pods -l app=splunk-otel-collector -o jsonpath='{.items[*].metadata.name}')
for pod in $pods; do
echo "Logs for $pod:"
kubectl logs $pod | head -n 2000
done