|
| 1 | +# Workflow which runs end to end tests against scalyr agent helm chart. |
| 2 | +# Those tests verify that the chart can be installed and that it correctly configured agent |
| 3 | +# ingestion for various options (daemonset mode, deployment mode, k8s cluster metrics are ingested, |
| 4 | +# pod logs are ingested, etc.) |
| 5 | +name: "End to End Tests" |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - end_to_end_tests |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + - end_to_end_tests |
| 16 | + schedule: |
| 17 | + - cron: '0 4 * * *' |
| 18 | + |
| 19 | +jobs: |
| 20 | + # Special job which automatically cancels old runs for the same branch, prevents runs for the |
| 21 | + # same file set which has already passed, etc. |
| 22 | + pre_job: |
| 23 | + name: Skip Duplicate Jobs Pre Job |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 27 | + steps: |
| 28 | + - id: skip_check |
| 29 | + uses: fkirc/skip-duplicate-actions@f75dd6564bb646f95277dc8c3b80612e46a4a1ea # v3.4.1 |
| 30 | + with: |
| 31 | + cancel_others: 'true' |
| 32 | + github_token: ${{ github.token }} |
| 33 | + |
| 34 | + daemonset_controller_type: |
| 35 | + name: Daemonset - k8s ${{ matrix.k8s_version }} |
| 36 | + runs-on: ubuntu-latest |
| 37 | + |
| 38 | + needs: pre_job |
| 39 | + # NOTE: We always want to run job on main branch |
| 40 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref == 'refs/heads/main' }} |
| 41 | + |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + k8s_version: |
| 46 | + - 'v1.16.4' |
| 47 | + - 'v1.17.2' |
| 48 | + - 'v1.22.2' |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout Repository |
| 52 | + uses: actions/checkout@v2 |
| 53 | + with: |
| 54 | + fetch-depth: 0 |
| 55 | + |
| 56 | + - name: Set up Chart Testing Environment and Kubernetes Cluster |
| 57 | + uses: ./.github/actions/setup-chart-testing-environment/ |
| 58 | + with: |
| 59 | + k8s_version: "${{ matrix.k8s_version }}" |
| 60 | + github_token: "${{ secrets.GITHUB_TOKEN }}" |
| 61 | + |
| 62 | + - name: Install Scalyr tool |
| 63 | + run: | |
| 64 | + curl https://raw.githubusercontent.com/scalyr/scalyr-tool/master/scalyr > scalyr |
| 65 | + chmod +x scalyr |
| 66 | + sudo mv scalyr /usr/local/bin |
| 67 | +
|
| 68 | + - name: Install Helm Chart |
| 69 | + uses: ./.github/actions/install-helm-chart |
| 70 | + with: |
| 71 | + scalyr_api_key: "${{ secrets.SCALYR_WRITE_API_KEY_US }}" |
| 72 | + values_file_path: "ci/daemonset-agent-values.yaml" |
| 73 | + |
| 74 | + - name: Verify Agent Logs are Ingested |
| 75 | + env: |
| 76 | + scalyr_readlog_token: "${{ secrets.SCALYR_READ_API_KEY_US }}" |
| 77 | + SCALYR_AGENT_POD_NAME: "${{ env.SCALYR_AGENT_POD_NAME }}" |
| 78 | + run: | |
| 79 | + # Verify agent and kubernetes monitor has been started |
| 80 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Starting scalyr agent..."' |
| 81 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "No checkpoints were found. All logs will be copied starting at their current end"' |
| 82 | +
|
| 83 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Cluster name detected, enabling k8s metric reporting"' |
| 84 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "kubernetes_monitor parameters: "' |
| 85 | +
|
| 86 | + # Verify Kubernetes metrics are beeing ingested |
| 87 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/kubernetes_monitor.log" "k8s-daemon-set=\"scalyr-agent\""' |
| 88 | +
|
| 89 | + # We install Redis helm chart and later verify that logs from Redis pods are successfully ingested |
| 90 | + - name: Install Redis Helm Chart |
| 91 | + run: | |
| 92 | + helm repo add bitnami https://charts.bitnami.com/bitnami |
| 93 | + helm install --wait --values ci/redis-values.yaml redis-test bitnami/redis |
| 94 | +
|
| 95 | + sleep 20 |
| 96 | +
|
| 97 | + - name: Verify Redis Pods Logs are Ingested |
| 98 | + env: |
| 99 | + scalyr_readlog_token: "${{ secrets.SCALYR_READ_API_KEY_US }}" |
| 100 | + SCALYR_AGENT_POD_NAME: "${{ env.SCALYR_AGENT_POD_NAME }}" |
| 101 | + run: | |
| 102 | + # master pod |
| 103 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile contains "redis" pod_name="redis-test-master-0" "Redis is starting"' |
| 104 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile contains "redis" pod_name="redis-test-master-0" "Configuration loaded"' |
| 105 | +
|
| 106 | + # replica pod |
| 107 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile contains "redis" pod_name="redis-test-replicas-0" "MASTER <-> REPLICA sync started"' |
| 108 | +
|
| 109 | + # TODO: Enable once the repo has been moved |
| 110 | + # - name: Notify Slack on Failure |
| 111 | + # # NOTE: github.ref is set to pr ref (and not branch name, e.g. refs/pull/28/merge) for pull |
| 112 | + # # requests and that's why we need this special conditional and check for github.head_ref in |
| 113 | + # # case of PRs |
| 114 | + # if: ${{ failure() && (github.ref == 'refs/heads/main' || github.head_ref == 'main') }} |
| 115 | + # uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2 |
| 116 | + # env: |
| 117 | + # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 118 | + # with: |
| 119 | + # status: ${{ job.status }} |
| 120 | + # steps: ${{ toJson(steps) }} |
| 121 | + # channel: '#cloud-tech' |
| 122 | + |
| 123 | + deployment_controller_type: |
| 124 | + name: Deployment - k8s ${{ matrix.k8s_version }} |
| 125 | + runs-on: ubuntu-latest |
| 126 | + |
| 127 | + needs: pre_job |
| 128 | + # NOTE: We always want to run job on main branch |
| 129 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref == 'refs/heads/main' }} |
| 130 | + |
| 131 | + strategy: |
| 132 | + fail-fast: false |
| 133 | + matrix: |
| 134 | + k8s_version: |
| 135 | + - 'v1.16.4' |
| 136 | + - 'v1.17.2' |
| 137 | + - 'v1.22.2' |
| 138 | + |
| 139 | + steps: |
| 140 | + - name: Checkout Repository |
| 141 | + uses: actions/checkout@v2 |
| 142 | + with: |
| 143 | + fetch-depth: 0 |
| 144 | + |
| 145 | + - name: Set up Chart Testing Environment and Kubernetes Cluster |
| 146 | + uses: ./.github/actions/setup-chart-testing-environment/ |
| 147 | + with: |
| 148 | + k8s_version: "${{ matrix.k8s_version }}" |
| 149 | + github_token: "${{ secrets.GITHUB_TOKEN }}" |
| 150 | + |
| 151 | + - name: Install Scalyr tool |
| 152 | + run: | |
| 153 | + curl https://raw.githubusercontent.com/scalyr/scalyr-tool/master/scalyr > scalyr |
| 154 | + chmod +x scalyr |
| 155 | + sudo mv scalyr /usr/local/bin |
| 156 | +
|
| 157 | + - name: Install Helm Chart |
| 158 | + uses: ./.github/actions/install-helm-chart |
| 159 | + with: |
| 160 | + scalyr_api_key: "${{ secrets.SCALYR_WRITE_API_KEY_US }}" |
| 161 | + values_file_path: "ci/deployment-agent-values.yaml" |
| 162 | + |
| 163 | + - name: Verify Logs are Ingested |
| 164 | + env: |
| 165 | + scalyr_readlog_token: "${{ secrets.SCALYR_READ_API_KEY_US }}" |
| 166 | + SCALYR_AGENT_POD_NAME: "${{ env.SCALYR_AGENT_POD_NAME }}" |
| 167 | + run: | |
| 168 | + export POD_NAME=$(kubectl get pod --selector=test=true -o jsonpath="{.items[0].metadata.name}") |
| 169 | +
|
| 170 | + # Verify agent and kubernetes monitor has been started |
| 171 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Starting scalyr agent..."' |
| 172 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "No checkpoints were found. All logs will be copied starting at their current end"' |
| 173 | +
|
| 174 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Cluster name detected, enabling k8s metric reporting"' |
| 175 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "kubernetes_monitor parameters: "' |
| 176 | +
|
| 177 | + # Verify Kubernetes metrics are beeing ingested |
| 178 | + ./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/kubernetes_monitor.log" "k8s-deployment=\"scalyr-agent\""' |
| 179 | +
|
| 180 | + - name: Notify Slack on Failure |
| 181 | + # NOTE: github.ref is set to pr ref (and not branch name, e.g. refs/pull/28/merge) for pull |
| 182 | + # requests and that's why we need this special conditional and check for github.head_ref in |
| 183 | + # case of PRs |
| 184 | + if: ${{ failure() && (github.ref == 'refs/heads/main' || github.head_ref == 'main') }} |
| 185 | + uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2 |
| 186 | + env: |
| 187 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 188 | + with: |
| 189 | + status: ${{ job.status }} |
| 190 | + steps: ${{ toJson(steps) }} |
| 191 | + channel: '#cloud-tech' |
0 commit comments