Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test helm all k8s available versions #728

Merged
merged 36 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6ce1970
Test k8s matrix sanity check
jaroslav-fedor-swi Sep 18, 2024
847ddde
Run matrix in helm e2e action
jaroslav-fedor-swi Sep 19, 2024
7d5b2de
Debug integration test
jaroslav-fedor-swi Sep 19, 2024
e741fa8
Add more verbosity
jaroslav-fedor-swi Sep 19, 2024
e7e13c8
Increase timeout
jaroslav-fedor-swi Sep 19, 2024
8772eea
fix timemout
jaroslav-fedor-swi Sep 19, 2024
1be67c8
Copy integration-test image in kind
jaroslav-fedor-swi Sep 19, 2024
fbfd8c1
Typo
jaroslav-fedor-swi Sep 19, 2024
e14ad29
Typo
jaroslav-fedor-swi Sep 19, 2024
0f1d8bc
Bump skafold + rename kind cluster
jaroslav-fedor-swi Sep 19, 2024
6bf6731
Fix context for deploy
jaroslav-fedor-swi Sep 19, 2024
0ce8f46
fix context name pt2
jaroslav-fedor-swi Sep 19, 2024
891144f
revert some changes back + cleanup
jaroslav-fedor-swi Sep 19, 2024
34b4cf1
Revert skafold version
jaroslav-fedor-swi Sep 19, 2024
60840fd
Add install of kubetail
jaroslav-fedor-swi Sep 19, 2024
d6005b9
Disable 1.31 as failing tests
jaroslav-fedor-swi Sep 19, 2024
0706569
Disable most version
jaroslav-fedor-swi Sep 19, 2024
6733b16
Enable debuging
jaroslav-fedor-swi Sep 20, 2024
69266dd
Change test log message
jaroslav-fedor-swi Sep 20, 2024
b006eed
Test remove metric not reported by kind
jaroslav-fedor-swi Sep 20, 2024
2198045
Dont remove testing pod to check its output
jaroslav-fedor-swi Sep 20, 2024
5c59247
Increase timeout
jaroslav-fedor-swi Sep 20, 2024
01703fc
Double timeout
jaroslav-fedor-swi Sep 20, 2024
88a47a8
Less verbose debug msg
jaroslav-fedor-swi Sep 20, 2024
32c3899
Update some messaging + upload otel logs
jaroslav-fedor-swi Sep 20, 2024
109fe19
Try change assertion
jaroslav-fedor-swi Sep 20, 2024
6fd4f19
Dump raw data to file instead of stdout
jaroslav-fedor-swi Sep 20, 2024
c3c786a
Make logs more readable
jaroslav-fedor-swi Sep 20, 2024
1b7e903
Wait for timeseries to be raedy before test
jaroslav-fedor-swi Sep 20, 2024
67a9a5a
Make output more readble
jaroslav-fedor-swi Sep 20, 2024
9841ef8
Enable all versions
jaroslav-fedor-swi Sep 20, 2024
8ffe2a5
Remove debug + use kind for image test
jaroslav-fedor-swi Sep 20, 2024
6824bbe
Show all resource on fail
jaroslav-fedor-swi Sep 20, 2024
e72f6e9
Copy collector images to kind
jaroslav-fedor-swi Sep 20, 2024
f937cf2
Some polishing
jaroslav-fedor-swi Sep 20, 2024
3caf1e8
Merge branch 'master' into matrix-test
jaroslav-fedor-swi Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/actions/run-integration-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ runs:
steps:
- name: Run Integration tests
run: |
kubectl wait --for=condition=ready --timeout=60s pod -l app=timeseries-mock-service -n test-namespace

kubectl create job --from=cronjob/integration-test integration-test-manual -n test-namespace

kubectl wait --for=condition=ready --timeout=60s pod -l job-name=integration-test-manual -n test-namespace
kubetail -l job-name=integration-test-manual -n test-namespace &

# Wait for either complete or failed
echo "Waiting for tests to complete"
while true; do
if kubectl wait --for=condition=complete --timeout=0 jobs/integration-test-manual -n test-namespace 2>/dev/null; then
job_result=0
Expand All @@ -21,8 +24,7 @@ runs:
job_result=1
break
fi

echo "Waiting for tests to complete"
echo -n "."
sleep 3
done

Expand All @@ -38,7 +40,7 @@ runs:
kubectl logs -n test-namespace $pod -c $container > pod-logs/$container.txt
done
done

mv raw_bodies_dump.txt pod-logs/
exit 1
fi

Expand Down
31 changes: 26 additions & 5 deletions .github/workflows/buildAndDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ jobs:
- name: Deploy skaffold
uses: ./.github/actions/deploy-skaffold

- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
version: v0.24.0
kubectl_version: v1.31.0
node_image: kindest/node:v1.31.0
cluster_name: kind

- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

- name: Generate docker image tag
id: generate-tag
run: echo "::set-output name=value::v${{ github.run_number }}-$(git rev-parse --short HEAD)"
Expand All @@ -41,15 +53,24 @@ jobs:
- name: Test
run: skaffold test --build-artifacts=/tmp/tags.json

- name: Deploy kubernetes
uses: ./.github/actions/deploy-kubernetes
- name: Copy image to Kind cluster
run: |
kind load docker-image $(jq -r '.builds[] | select(.imageName=="integration-test") | .tag' /tmp/tags.json)
kind load docker-image $(jq -r '.builds[] | select(.imageName=="swi-k8s-opentelemetry-collector") | .tag' /tmp/tags.json)
kind load docker-image $(jq -r '.builds[] | select(.imageName=="swi-k8s-opentelemetry-collector-tests") | .tag' /tmp/tags.json)

- name: Add dependency chart repos
- name: Setup kubetail
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
curl -Lo kubetail https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail && sudo install kubetail /usr/local/bin/
shell: bash

- name: Deploy services using Skaffold
run: skaffold deploy --build-artifacts=/tmp/tags.json
run: skaffold deploy --build-artifacts=/tmp/tags.json --kube-context kind-kind

- name: Show all resources
if: ${{ failure() }}
run: |
kubectl get all -n test-namespace

- name: Run integration tests
uses: ./.github/actions/run-integration-tests
Expand Down
40 changes: 37 additions & 3 deletions .github/workflows/buildAndTestHelm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,32 @@ jobs:
name: Helm e2e tests
outputs:
image_tag: ${{ steps.generate-tag.outputs.value }}

strategy:
matrix:
# Kubernetes versions to test on
kubernetes_version:
- v1.25.16
- v1.26.15
- v1.27.16
- v1.28.13
- v1.29.8
- v1.30.4
- v1.31.0
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy skaffold
uses: ./.github/actions/deploy-skaffold

- name: Deploy kubernetes
uses: ./.github/actions/deploy-kubernetes
- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
version: v0.24.0
kubectl_version: ${{ matrix.kubernetes_version }}
node_image: kindest/node:${{ matrix.kubernetes_version }}
cluster_name: kind

- name: Add dependency chart repos
run: |
Expand All @@ -68,12 +85,29 @@ jobs:
- name: Build
run: skaffold build -p=ci-helm-e2e --file-output=/tmp/tags.json

- name: Copy image to Kind cluster
run: |
kind load docker-image $(jq -r '.builds[] | select(.imageName=="integration-test") | .tag' /tmp/tags.json)

- name: Setup kubetail
run: |
curl -Lo kubetail https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail && sudo install kubetail /usr/local/bin/
shell: bash

- name: Deploy services using Skaffold
run: skaffold deploy -p=ci-helm-e2e --build-artifacts=/tmp/tags.json
run: |
skaffold deploy -p=ci-helm-e2e \
--build-artifacts=/tmp/tags.json \
--kube-context kind-kind

- name: Show all resources
run: |
kubectl get all -n test-namespace

- name: Run integration tests
uses: ./.github/actions/run-integration-tests


helm_test_auto_update_against_last_published:
runs-on: ubuntu-latest
name: Helm auto update test
Expand Down
1 change: 0 additions & 1 deletion tests/integration/expected_metric_names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ k8s.node.network.transmit_packets_dropped
k8s.node.pods
k8s.node.status.condition.diskpressure
k8s.node.status.condition.memorypressure
k8s.node.status.condition.networkunavailable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind cluster does not have this metric...

k8s.node.status.condition.pidpressure
k8s.node.status.condition.ready
k8s.persistentvolumeclaim.status.phase
Expand Down
14 changes: 10 additions & 4 deletions tests/integration/test_log_collection.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest
import os
import json
from test_utils import get_all_bodies_for_all_sent_content, retry_until_ok, run_shell_command

endpoint = os.getenv("TIMESERIES_MOCK_ENDPOINT", "localhost:8088")
url = f'http://{endpoint}/logs.json'
pod_name = 'dummy-logging-pod'
tested_log = '!!testlog!!'
tested_log = 'testlog-swo-k8s-collector-integration-test'

def setup_function():
run_shell_command(f'kubectl run {pod_name} --image bash:alpine3.19 -n default -- -ec "while :; do echo \'{tested_log}\'; sleep 5 ; done"')
Expand All @@ -18,12 +19,17 @@ def test_logs_generated():

def assert_test_log_found(content):
raw_bodies = get_all_bodies_for_all_sent_content(content)
test_log_found = any(f'{tested_log}\n' in body for body in raw_bodies)
test_log_found = any(f'{tested_log}' in body for body in raw_bodies)
return test_log_found

def print_failure(content):
raw_bodies = get_all_bodies_for_all_sent_content(content)
print(f'Failed to find {tested_log}')
print('Sent logs:')
print(raw_bodies)
print('All logs in raw_bodies_dump.txt')
#print(raw_bodies)
# Dump the raw_bodies to a file
with open('raw_bodies_dump.txt', 'w') as file:
# Convert the list to a JSON string for better formatting
json.dump(raw_bodies, file, indent=4)


6 changes: 3 additions & 3 deletions tests/integration/test_metric_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_expected_otel_message_content_is_generated(file_name):
resource_attributes = test_case["resource_attributes"]
metrics = test_case["metrics"]

print(f'Checking metrics {metrics} with resource attributes {resource_attributes}')
print(f'Checking metrics {[item['name'] for item in metrics]} with resource attributes {resource_attributes}')

retry_until_ok(url,
lambda content: assert_test_contain_expected_datapoints(content, metrics, resource_attributes),
Expand Down Expand Up @@ -205,7 +205,7 @@ def assert_test_contain_expected_datapoints(content, metrics, resource_attribute
# Loop through each metric
for metric in scope["metrics"]:
if metric["name"] == metric_in_test_case["name"]:
print(f'Found metric {metric_in_test_case["name"]} in resource group')
print(f'Found metric {metric_in_test_case["name"]}')
test_case_passed = True

# Default to empty list if 'attributes' key is not present
Expand Down Expand Up @@ -247,7 +247,7 @@ def assert_test_contain_expected_datapoints(content, metrics, resource_attribute
break # Metric found, break the resource loop

if not test_case_passed:
return (False, f'Failed to find metric {metric_in_test_case["name"]} in resource group')
return (False, f'Failed to find metric {metric_in_test_case["name"]}')

return (True, '')

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_all_resources_for_all_sent_content(content):
return [get_all_log_resources(log_bulk) for log_bulk in log_bulks]


def retry_until_ok(url, func, print_failure, timeout = 240):
def retry_until_ok(url, func, print_failure, timeout = 600):
start_time = time.time()
last_exception = None
last_error = ''
Expand All @@ -48,8 +48,8 @@ def retry_until_ok(url, func, print_failure, timeout = 240):
print(e, traceback.format_exc())

if response is not None and response.status_code == 200:
if( last_error == ''):
print("Successfully downloaded!")
if( last_error != ''):
print(last_error)
result = func(response.content)
if( type(result) != tuple):
is_ok = result
Expand Down
Loading