Skip to content

Commit

Permalink
Merge pull request #517 from logzio/feature/logzio-monitoring-multi-e…
Browse files Browse the repository at this point in the history
…nv-tests

Add automatic tests for `logzio-monitoring` chart
  • Loading branch information
yotamloe authored Jul 17, 2024
2 parents 337ba13 + 03e37ef commit 2418177
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 0 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/logzio-monitoring-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Test Logzio Monitoring Helm Chart on EKS Kubernetes Environments

on:
pull_request:
branches:
- master
paths:
- 'charts/logzio-monitoring/**'
jobs:
test-helm-chart:
name: Test Helm Chart
runs-on: ubuntu-latest
strategy:
matrix:
environment: [eks-linux]

steps:
- name: Generate random id
id: random_id
run: echo "::set-output name=rand::$(echo $RANDOM)"

- name: Set ENV_ID
run: echo "ENV_ID=monitoring-test-run-${{ steps.random_id.outputs.rand }}-${{ matrix.environment }}" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Set up Helm
uses: azure/setup-helm@v4.2.0

- name: Set up kubectl
uses: azure/setup-kubectl@v4

- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- name: Set up eksctl
run: |
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
# (Optional) Verify checksum
curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check
tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
sudo mv /tmp/eksctl /usr/local/bin
- name: Provision Cluster
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
NUMBER_OF_NODES: 3
AWS_REGION: us-west-1
run: |
eksctl create cluster --name ${{ env.ENV_ID }}-${{ matrix.environment }} --region ${{ env.AWS_REGION }} --nodes {{ env.NUMBER_OF_NODES }}
aws eks --region ${{ env.AWS_REGION }} update-kubeconfig --name ${{ env.ENV_ID }}-${{ matrix.environment }}
- name: Label Nodes
run: |
kubectl get nodes -o name | xargs -I {} kubectl label {} node-role.kubernetes.io/worker=worker --overwrite
- name: Deploy Helm Chart
run: |
cd charts/logzio-monitoring
helm dependency build
helm upgrade --install \
--set logs.enabled=true \
--set logzio-logs-collector.enabled=true \
--set logzio-logs-collector.secrets.logzioLogsToken="${{ secrets.LOGZIO_LOGS_TOKEN }}" \
--set logzio-logs-collector.secrets.logzioRegion="us" \
--set logzio-logs-collector.secrets.env_id="${{ env.ENV_ID }}" \
--set secrets.logType="test" \
--set metricsOrTraces.enabled=true \
--set logzio-k8s-telemetry.metrics.enabled=true \
--set logzio-k8s-telemetry.secrets.MetricsToken="${{ secrets.LOGZIO_METRICS_TOKEN }}" \
--set logzio-k8s-telemetry.secrets.ListenerHost="https://listener.logz.io:8053" \
--set logzio-k8s-telemetry.secrets.p8s_logzio_name="${{ env.ENV_ID }}" \
--set logzio-k8s-telemetry.traces.enabled=true \
--set logzio-k8s-telemetry.secrets.TracesToken="${{ secrets.LOGZIO_TRACES_TOKEN }}" \
--set logzio-k8s-telemetry.secrets.LogzioRegion="us" \
--set logzio-k8s-telemetry.spm.enabled=true \
--set logzio-k8s-telemetry.secrets.env_id="${{ env.ENV_ID }}" \
--set logzio-k8s-telemetry.secrets.SpmToken="${{ secrets.LOGZIO_METRICS_TOKEN }}" \
--set logzio-k8s-telemetry.serviceGraph.enabled=true \
logzio-monitoring .
kubectl rollout status deployment/logzio-monitoring-otel-collector-standalone --timeout=300s
kubectl rollout status deployment/logzio-monitoring-otel-collector-spm --timeout=300s
- name: run log generator
run: |
kubectl apply -f tests/resources/logsgen.yaml
kubectl rollout status deployment/log-generator --timeout=300s
- name: run trace generator
run: |
kubectl apply -f tests/resources/tracegen-monitoring.yaml
kubectl rollout status deployment/trace-gen --timeout=300s
- name: sleep
run: sleep 120

- name: Run Go Tests
env:
KUBERNETES_ENV: ${{ matrix.environment }}
LOGZIO_METRICS_API_KEY: ${{ secrets.LOGZIO_METRICS_API_KEY }}
LOGZIO_TRACES_API_KEY: ${{ secrets.LOGZIO_TRACES_API_KEY }}
LOGZIO_LOGS_API_KEY: ${{ secrets.LOGZIO_LOGS_API_KEY }}
run: |
go get go.uber.org/zap
go test -v ./tests/traces_e2e_test.go ./tests/common.go
go test -v ./tests/metrics_e2e_test.go ./tests/common.go
go test -v ./tests/logs_e2e_test.go ./tests/common.go
- name: Cleanup Environment
run: |
helm uninstall logzio-monitoring
- name: Delete Cluster
if: always()
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-1
run: |
eksctl delete cluster --name ${{ env.ENV_ID }}-${{ matrix.environment }} --region ${{ env.AWS_REGION }}
24 changes: 24 additions & 0 deletions tests/resources/tracegen-monitoring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: trace-gen
spec:
selector:
matchLabels:
app: trace-gen
template:
metadata:
labels:
app: trace-gen
spec:
containers:
- name: trace-gen
image: ghcr.io/frzifus/jaeger-otel-test:latest
args:
[
'-otel.agent.host=logzio-monitoring-otel-collector',
'-otel.agent.port=4317',
]
env:
- name: OTEL_SERVICE_NAME
value: 'local-test-service'

0 comments on commit 2418177

Please sign in to comment.