End to end tests in Golang #1580
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Splunk Platform Functional Test | |
on: pull_request | |
jobs: | |
e2e-test: | |
name: Kubernetes ${{ matrix.kubernetes_version }} ${{ matrix.container_runtime }} | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
# The kubernetes_version matrix entries are currently following native Kubernetes version support and +1, see: https://endoflife.date/kubernetes | |
# TODO: Automate updating this and expand/contract matrix coverage for other Kubernetes distributions | |
kubernetes_version: | |
- v1.28.0 # Support: 28 Aug 2024 - 28 Oct 2024 | |
- v1.27.4 # Support: 28 Apr 2024 - 28 Jun 2024 | |
- v1.26.7 # Support: 28 Dec 2023 - 28 Feb 2024 | |
- v1.25.12 # Support: 27 Aug 2023 - 27 Oct 2023 | |
- v1.24.16 # Support: 28 May 2023 - 28 Jul 2023 | |
container_runtime: | |
- "docker" | |
- "containerd" | |
- "cri-o" | |
env: | |
CI_SPLUNK_PORT: 8089 | |
CI_SPLUNK_USERNAME: admin | |
CI_SPLUNK_HEC_TOKEN: a6b5e77f-d5f6-415a-bd43-930cecb12959 | |
CI_SPLUNK_PASSWORD: helloworld | |
CI_INDEX_EVENTS: ci_events | |
CI_INDEX_METRICS: ci_metrics | |
CONTAINER_RUNTIME: ${{ matrix.container_runtime }} | |
KUBERNETES_VERSION: ${{ matrix.kubernetes_version }} | |
MINIKUBE_VERSION: latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# # 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 ${HOME}/.kube | |
touch ${HOME}/.kube/config | |
# 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 | |
# 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 | |
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}}) | |
# Setup Indexes | |
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=$CI_INDEX_EVENTS -d datatype=event | |
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=ns-anno -d datatype=event | |
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=pod-anno -d datatype=event | |
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=$CI_INDEX_METRICS -d datatype=metric | |
# Enable HEC services | |
curl -X POST -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD -k https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/servicesNS/nobody/splunk_httpinput/data/inputs/http/http/enable | |
# Create new HEC token | |
curl -X POST -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD -k -d "name=splunk_hec_token&token=a6b5e77f-d5f6-415a-bd43-930cecb12959&disabled=0&index=main&indexes=main,ci_events,ci_metrics,ns-anno,pod-anno" https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/servicesNS/nobody/splunk_httpinput/data/inputs/http | |
# Restart Splunk | |
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/server/control/restart -X POST | |
- name: Deploy splunk-otel-collector chart | |
run: | | |
make repo-update dep-build | |
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}}) | |
# TODO: Remove NETWORK_EXPLORER_ENABLED after https://github.com/signalfx/splunk-otel-collector-chart/issues/896 | |
if [[ "$KUBERNETES_VERSION" == *1.24* ]]; then | |
echo "Detected Kubernetes version 1.24. Setting NETWORK_EXPLORER_ENABLED to true." | |
export NETWORK_EXPLORER_ENABLED=true | |
fi | |
ci_scripts/deploy_collector.sh | |
- name: Deploy log generator | |
run: | | |
kubectl apply -f test/test_setup.yaml | |
sleep 60 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Run functional tests | |
run: | | |
kubectl get nodes | |
export PYTHONWARNINGS="ignore:Unverified HTTPS request" | |
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}}) | |
cd test | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
echo "Running functional tests....." | |
python -m pytest \ | |
--splunkd-url https://$CI_SPLUNK_HOST:8089 \ | |
--splunk-user admin \ | |
--splunk-password $CI_SPLUNK_PASSWORD \ | |
-p no:warnings -s | |
# # Leave this here for debugging | |
# sleep 180 | |
# echo "Getting agent logs....." | |
# kubectl get pods -l release=ci-sck --no-headers=true | awk '/agent/{print $1}' | xargs kubectl logs | |
# echo "Getting collector logs....." | |
# kubectl get pods -l release=ci-sck --no-headers=true | awk '/cluster/{print $1}' | xargs kubectl logs | |
- name: Print splunk-otel-collector logs | |
if: always() | |
run: | | |
# Echo logs for the collector (agent,cluster-receiver,gateway) for visability | |
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 |