-
Notifications
You must be signed in to change notification settings - Fork 151
133 lines (122 loc) · 5.75 KB
/
functional_test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Splunk Platform Functional Test
on:
pull_request:
jobs:
functional-test:
name: K8s ${{ matrix.kubernetes_version }} ${{ matrix.container_runtime }}, Splunk ${{ matrix.splunk_version }}
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
# To check latest Minikube versions, see: https://raw.githubusercontent.com/kubernetes/minikube/master/pkg/minikube/constants/constants_kubernetes_versions.go
# TODO: Automate updating this and expand/contract matrix coverage for other Kubernetes distributions
kubernetes_version:
- v1.30.0 # Support: 28 Apr 2025 - 28 Jun 2025
- v1.29.4 # Support: 28 Dec 2024 - 28 Feb 2025
- v1.28.9 # Support: 28 Aug 2024 - 28 Oct 2024
- v1.27.13 # Support: 28 Apr 2024 - 28 Jun 2024
# Test current +1 out-of-date Kubernetes version to cover EKS's extended support version matrix
- v1.26.15 # Support: 28 Dec 2023 - 28 Feb 2024
container_runtime:
- "docker"
- "containerd"
- "cri-o"
splunk_version:
- 9.3.0
- 8.2.9
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.kubernetes_version }}
SPLUNK_VERSION: ${{ matrix.splunk_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
# 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
- uses: actions/setup-python@v5
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 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