Skip to content

Commit 4bb98ca

Browse files
authored
[TT-1806] add required chain.link labels (#1364)
1 parent 2f0c331 commit 4bb98ca

File tree

29 files changed

+594
-23
lines changed

29 files changed

+594
-23
lines changed

.github/workflows/k8s-publish-test-base-image.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
# we only need base image for k8s based tests
66
- 'lib/v*'
77
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag for the base image'
11+
required: true
12+
type: string
813

914
jobs:
1015
publish_test_base_image:
@@ -19,12 +24,20 @@ jobs:
1924
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
2025

2126
- name: Strip "lib/" from github.ref_name
27+
if: ${{ github.event_name == 'push' }}
2228
run: |
2329
stripped_ref_name="${GITHUB_REF//refs\/tags\/lib\//}"
2430
# disabling as the string containing variable is double-quotted as a whole, no need to quote each variable separately
2531
# shellcheck disable=SC2086
2632
echo "BASE_IMAGE_TAG=${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/test-base-image:$stripped_ref_name" >> $GITHUB_ENV
2733
34+
- name: Export base image tag for workflow dispatch
35+
if: ${{ github.event_name == 'workflow_dispatch' }}
36+
shell: bash
37+
run: |
38+
# shellcheck disable=SC2086
39+
echo "BASE_IMAGE_TAG=${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/test-base-image:${{ github.event.inputs.tag }}" >> $GITHUB_ENV
40+
2841
- name: Build Base Image
2942
uses: smartcontractkit/chainlink-github-actions/docker/build-push@d2f9642bcc24a73400568756f24b72c188ac7a9a # v2.3.31
3043
with:

book/src/k8s-test-runner/k8s-test-runner.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The TOML config should specify the test runner configuration as follows:
4545
```
4646
namespace = "e2e-tests"
4747
rbac_role_name = "" # RBAC role name for the chart
48+
rbac_service_account_name = "" # RBAC service account name for the chart
4849
image_registry_url = "" # URL to the ECR containing the test binary image, e.g., staging ECR URL
4950
image_name = "k8s-test-runner"
5051
image_tag = "" # The image tag to use, like "mercury-load-tests" (see readme above)
@@ -61,8 +62,16 @@ resources_limits_memory = "1024Mi"
6162
WASP_LOG_LEVEL = "info"
6263
TEST_LOG_LEVEL = "info"
6364
MERCURY_TEST_LOG_LEVEL = "info"
65+
[metadata.labels]
66+
"chain.link/component" = "test-runner"
67+
"chain.link/product" = "<your-product-name>"
68+
"chain.link/team" = "<name–of-the-team-you're-running-the-test-for>"
69+
"chain.link/cost-center" = "test-tooling-<testType>-test"
6470
```
6571

72+
> [NOTE]
73+
> Make sure to quote labels with "/" as otherwise parsing them will fail.
74+
6675
Where:
6776

6877
- `test_name` is the name of the test to run (must be included in the test binary).
@@ -113,6 +122,7 @@ Then:
113122
cat << EOF > config.toml
114123
namespace = "e2e-tests"
115124
rbac_role_name = "" # RBAC role name for the chart
125+
rbac_service_account_name = "" # RBAC service account name for the chart
116126
image_registry_url = "${{ secrets.AWS_ACCOUNT_ID_STAGING }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com"
117127
image_name = "k8s-test-runner"
118128
image_tag = "mercury-load-test"
@@ -130,6 +140,11 @@ Then:
130140
WASP_LOG_LEVEL = "info"
131141
TEST_LOG_LEVEL = "info"
132142
MERCURY_TEST_LOG_LEVEL = "info"
143+
[metadata.labels]
144+
"chain.link/component" = "test-runner"
145+
"chain.link/product" = "data-streamsv0.3"
146+
"chain.link/team" = "Data Streams"
147+
"chain.link/cost-center" = "test-tooling-load-test"
133148
EOF
134149
135150
./k8s-test-runner-linux-amd64 run -c config.toml

k8s-test-runner/chart/templates/job.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ metadata:
66
namespace: {{ $.Release.Namespace }}
77
labels:
88
sync: "{{ $.Values.sync }}"
9+
{{- range $key, $val := $.Values.metadata.labels }}
10+
{{- $e.key }}: "{{ $e.value }}"
11+
{{- end }}
912
spec:
1013
backoffLimit: 0
1114
ttlSecondsAfterFinished: {{ $.Values.ttlSecondsAfterFinished }}

k8s-test-runner/chart/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ labels:
1515
annotations: {}
1616
env:
1717
# TEST_LOG_LEVEL: ''
18+
metadata:
19+
labels:
20+
# label: value
1821
resources:
1922
requests:
2023
cpu: 1000m

k8s-test-runner/cmd/internal/run.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func getChartOverrides(c config.Runner) map[string]interface{} {
8585
}
8686
envMap[c.TestConfigBase64EnvName] = c.TestConfigBase64
8787

88+
labelsMap := c.Metadata.Labels
89+
if labelsMap == nil {
90+
labelsMap = make(map[string]string)
91+
}
92+
8893
return map[string]interface{}{
8994
"namespace": c.Namespace,
9095
"rbac": map[string]interface{}{
@@ -102,7 +107,10 @@ func getChartOverrides(c config.Runner) map[string]interface{} {
102107
"imagePullPolicy": "Always",
103108
"labels": map[string]interface{}{},
104109
"annotations": map[string]interface{}{}, // Add specific annotations if needed
105-
"env": envMap,
110+
"metadata": map[string]interface{}{
111+
"labels": labelsMap,
112+
},
113+
"env": envMap,
106114
"resources": map[string]interface{}{
107115
"requests": map[string]interface{}{
108116
"cpu": c.ResourcesRequestsCPU,

k8s-test-runner/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ type Runner struct {
3434
DetachedMode bool `toml:"detached_mode"`
3535
Debug bool `toml:"debug"`
3636
Envs map[string]string `toml:"envs"`
37+
Metadata Metadata `toml:"metadata"`
38+
}
39+
40+
type Metadata struct {
41+
Labels map[string]string `toml:"labels"`
3742
}
3843

3944
// Read initializes the configuration by sequentially loading from a TOML file,

lib/k8s/config/overrides.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const (
4646
EnvVarUserDescription = "Owner of an environment"
4747
EnvVarUserExample = "Satoshi"
4848

49+
EnvVarTeam = "CHAINLINK_USER_TEAM"
50+
EnvVarTeamDescription = "Team to, which owner of the environment belongs to"
51+
EnvVarTeamExample = "BIX, CCIP, BCM"
52+
4953
EnvVarCLCommitSha = "CHAINLINK_COMMIT_SHA"
5054
EnvVarCLCommitShaDescription = "The sha of the commit that you're running tests on. Mostly used for CI"
5155
EnvVarCLCommitShaExample = "${{ github.sha }}"

0 commit comments

Comments
 (0)