Skip to content

Commit

Permalink
Set dynamic env vars for test (#642)
Browse files Browse the repository at this point in the history
* Set dynamic env vars for test

* Fix

* Update codeowners

* Make PROD_AWS_ACCOUNT_NUMBER required

* Fix

* Fix

* More fixes
  • Loading branch information
lukaszcl committed Sep 26, 2024
1 parent ba7692f commit 827d85b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
69 changes: 39 additions & 30 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ on:
required: true
QA_AWS_ACCOUNT_NUMBER:
required: true
PROD_AWS_ACCOUNT_NUMBER:
required: true
QA_PYROSCOPE_INSTANCE:
required: true
QA_PYROSCOPE_KEY:
Expand Down Expand Up @@ -217,8 +219,6 @@ on:
# Used in some tests to send slack notifications
SLACK_CHANNEL:
required: false
AWS_ACCOUNT_ID_PROD:
required: false

env:
CHAINLINK_IMAGE:
Expand All @@ -242,6 +242,9 @@ env:
${{ inputs.slack_notification_after_tests_channel_id || inputs.SLACK_CHANNEL
|| secrets.SLACK_CHANNEL }}
SLACK_USER: ${{ inputs.SLACK_USER }}
E2E_JD_IMAGE:
${{ secrets.PROD_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{
secrets.AWS_REGION}}.amazonaws.com/job-distributor

jobs:
validate-inputs:
Expand Down Expand Up @@ -646,6 +649,22 @@ jobs:
--user "$(id -u):$(id -g)" \
-p 4317:4317 otel/opentelemetry-collector:0.88.0 --config=/etc/otel-collector.yaml
- name: Set dynamic env vars for tests
shell: bash
run: |
json_content='${{ toJson(matrix.tests.test_env_vars) }}'
test_id='${{ matrix.tests.id }}'
# Check if json_content is non-empty and is a valid JSON object that is not null
if [ -z "$json_content" ] || [ "$json_content" = 'null' ] || ! echo "$json_content" | jq -e .; then
echo "No dynamic environment variables for $test_id."
else
echo "$json_content" | jq -r 'to_entries | .[] | "\(.key)=\(.value)"' | while IFS='=' read -r key value; do
echo "Setting $key=$value for $test_id"
echo "$key=$value" >> "$GITHUB_ENV"
done
fi
- name: Run tests
id: run_tests
uses: smartcontractkit/.github/actions/ctf-run-tests@b8731364b119e88983e94b0c4da87fc27ddb41b8 # ctf-run-tests@0.0.0
Expand All @@ -654,21 +673,12 @@ jobs:
E2E_TEST_CHAINLINK_VERSION:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_VERSION ||
env.DEFAULT_CHAINLINK_VERSION }}
E2E_TEST_CHAINLINK_UPGRADE_VERSION:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_UPGRADE_VERSION }}
E2E_TEST_CHAINLINK_POSTGRES_VERSION:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_POSTGRES_VERSION
}}
E2E_TEST_SELECTED_NETWORK:
${{ matrix.tests.test_env_vars.E2E_TEST_SELECTED_NETWORK }}
E2E_TEST_LOGGING_RUN_ID: ${{ github.run_id }}
E2E_TEST_LOG_STREAM_LOG_TARGETS: ${{ vars.LOGSTREAM_LOG_TARGETS }}
E2E_TEST_LOG_COLLECT: ${{ vars.TEST_LOG_COLLECT }}
E2E_TEST_LOKI_TENANT_ID: ${{ secrets.LOKI_TENANT_ID }}
E2E_TEST_LOKI_ENDPOINT: ${{ secrets.LOKI_URL }}
E2E_TEST_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }}
E2E_TEST_GRAFANA_DASHBOARD_URL:
${{ matrix.tests.test_env_vars.E2E_TEST_GRAFANA_DASHBOARD_URL }}
E2E_TEST_GRAFANA_BEARER_TOKEN:
${{ secrets.GRAFANA_INTERNAL_URL_SHORTENER_TOKEN }}
E2E_TEST_PYROSCOPE_ENVIRONMENT: ${{ matrix.tests.pyroscope_env }}
Expand All @@ -678,10 +688,6 @@ jobs:
E2E_TEST_PYROSCOPE_KEY:
${{ matrix.tests.pyroscope_env != '' && secrets.QA_PYROSCOPE_KEY ||
'' }}
E2E_JD_IMAGE:
${{ secrets.AWS_ACCOUNT_ID_PROD }}.dkr.ecr.${{ secrets.AWS_REGION
}}.amazonaws.com/job-distributor
E2E_JD_VERSION: 0.4.0
with:
test_command_to_run:
${{ matrix.tests.test_cmd }} ${{ matrix.tests.test_cmd_opts || '2>&1
Expand All @@ -700,8 +706,8 @@ jobs:
default_e2e_test_chainlink_upgrade_image:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_UPGRADE_IMAGE }}
aws_registries:
${{ secrets.QA_AWS_ACCOUNT_NUMBER }},${{ secrets.AWS_ACCOUNT_ID_PROD
}}
${{ secrets.QA_AWS_ACCOUNT_NUMBER }},${{
secrets.PROD_AWS_ACCOUNT_NUMBER }}
artifacts_name: ${{ env.TEST_ID }}-test-logs
artifacts_location: |
./integration-tests/smoke/logs/
Expand Down Expand Up @@ -915,6 +921,22 @@ jobs:
- name: Show test configuration in logs
run: echo '${{ toJson(matrix.tests) }}' | jq .

- name: Set dynamic env vars for tests
shell: bash
run: |
json_content='${{ toJson(matrix.tests.test_env_vars) }}'
test_id='${{ matrix.tests.id }}'
# Check if json_content is non-empty and is a valid JSON object that is not null
if [ -z "$json_content" ] || [ "$json_content" = 'null' ] || ! echo "$json_content" | jq -e .; then
echo "No dynamic environment variables for $test_id."
else
echo "$json_content" | jq -r 'to_entries | .[] | "\(.key)=\(.value)"' | while IFS='=' read -r key value; do
echo "Setting $key=$value for $test_id"
echo "$key=$value" >> "$GITHUB_ENV"
done
fi
- name: Run tests
id: run_tests
uses: smartcontractkit/.github/actions/ctf-run-tests@b6e37806737eef87e8c9137ceeb23ef0bff8b1db # ctf-run-tests@0.1.0
Expand All @@ -932,29 +954,16 @@ jobs:
${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{
secrets.QA_AWS_REGION }}.amazonaws.com
# We can comment these out when we have a stable soak test and aren't worried about resource consumption
TEST_UPLOAD_CPU_PROFILE:
${{ matrix.tests.test_env_vars.TEST_UPLOAD_CPU_PROFILE }}
TEST_UPLOAD_MEM_PROFILE:
${{ matrix.tests.test_env_vars.TEST_UPLOAD_MEM_PROFILE }}
REF_NAME: ${{ github.head_ref || github.ref_name }}
E2E_TEST_CHAINLINK_VERSION:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_VERSION ||
env.DEFAULT_CHAINLINK_VERSION }}
E2E_TEST_CHAINLINK_UPGRADE_VERSION:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_UPGRADE_VERSION }}
E2E_TEST_CHAINLINK_POSTGRES_VERSION:
${{ matrix.tests.test_env_vars.E2E_TEST_CHAINLINK_POSTGRES_VERSION
}}
E2E_TEST_SELECTED_NETWORK:
${{ matrix.tests.test_env_vars.E2E_TEST_SELECTED_NETWORK }}
E2E_TEST_LOGGING_RUN_ID: ${{ github.run_id }}
E2E_TEST_LOG_STREAM_LOG_TARGETS: ${{ vars.LOGSTREAM_LOG_TARGETS }}
E2E_TEST_LOG_COLLECT: ${{ vars.TEST_LOG_COLLECT }}
E2E_TEST_LOKI_TENANT_ID: ${{ secrets.LOKI_TENANT_ID }}
E2E_TEST_LOKI_ENDPOINT: ${{ secrets.LOKI_URL }}
E2E_TEST_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }}
E2E_TEST_GRAFANA_DASHBOARD_URL:
${{ matrix.tests.test_env_vars.E2E_TEST_GRAFANA_DASHBOARD_URL }}
E2E_TEST_GRAFANA_BEARER_TOKEN:
${{ secrets.GRAFANA_INTERNAL_URL_SHORTENER_TOKEN }}
E2E_TEST_PYROSCOPE_ENVIRONMENT: ${{ matrix.tests.pyroscope_env }}
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

# Chainlink Testing Framework (CTF)
/actions/ctf-*/** @smartcontractkit/test-tooling-team
.github/workflows/run-e2e-tests.yml @smartcontractkit/test-tooling-team

0 comments on commit 827d85b

Please sign in to comment.