Skip to content

Commit 3dded98

Browse files
authored
Enable k8s tests (#1498)
1 parent 562a870 commit 3dded98

File tree

7 files changed

+51
-24
lines changed

7 files changed

+51
-24
lines changed

.github/workflows/k8s-e2e.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: (k8s package) E2E tests
2-
# disabling for now, as they always fail
3-
#on:
4-
# pull_request:
2+
on:
3+
pull_request:
54

65
concurrency:
76
group: e2e-tests-k8s-${{ github.ref }}
@@ -74,7 +73,7 @@ jobs:
7473
- name: Load Nix
7574
run: nix develop -c sh -c "cd lib &&go mod download"
7675
- name: Setup environment
77-
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-run-tests-environment@d2f9642bcc24a73400568756f24b72c188ac7a9a # v2.3.31
76+
uses: smartcontractkit/.github/actions/ctf-setup-run-tests-environment@49cb1613e96c9ce17f7290e4dabd38f43aa9bd4d # [email protected]
7877
with:
7978
go_mod_path: go.mod
8079
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
@@ -84,7 +83,7 @@ jobs:
8483
- name: Run Tests
8584
env:
8685
LOCAL_CHARTS: true
87-
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@d2f9642bcc24a73400568756f24b72c188ac7a9a # v2.3.31
86+
uses: smartcontractkit/.github/actions/ctf-run-tests@b8731364b119e88983e94b0c4da87fc27ddb41b8 # [email protected]
8887
with:
8988
cl_repo: ${{ env.CHAINLINK_IMAGE }}
9089
cl_image_tag: ${{ env.CHAINLINK_VERSION }}
@@ -97,7 +96,6 @@ jobs:
9796
go_mod_path: go.mod
9897
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
9998
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
100-
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
10199
run_setup: false
102100
- name: Upload test log
103101
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3

lib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ k8s_test_e2e:
123123
go test ./k8s/e2e/local-runner -count 1 -test.parallel=12 -v $(args)
124124

125125
k8s_test_e2e_ci: go_mod
126-
go test ./k8s/e2e/local-runner -count 1 -test.parallel=14 -test.timeout=1h -json 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci -singlepackage
126+
CHAINLINK_USER_TEAM=TT go test ./k8s/e2e/local-runner -count 1 -test.parallel=14 -test.timeout=1h -json 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci -singlepackage
127127

128128
k8s_test_e2e_ci_remote_runner: go_mod
129-
go test ./k8s/e2e/remote-runner -count 1 -test.parallel=20 -test.timeout=1h -json 2>&1 | tee /tmp/remoterunnergotest.log | gotestloghelper -ci -singlepackage
129+
CHAINLINK_USER_TEAM=TT go test ./k8s/e2e/remote-runner -count 1 -test.parallel=20 -test.timeout=1h -json 2>&1 | tee /tmp/remoterunnergotest.log | gotestloghelper -ci -singlepackage
130130

131131
.PHONY: examples
132132
examples:

lib/k8s/e2e/common/test_common.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ var (
3333
)
3434

3535
func GetTestEnvConfig(t *testing.T) *environment.Config {
36+
testType := "functional"
37+
product := "internal-k8s-test-runner"
38+
39+
nsLabels, err := environment.GetRequiredChainLinkNamespaceLabels(product, testType)
40+
require.NoError(t, err, "Error creating required chain.link labels for namespace")
41+
42+
workloadPodLabels, err := environment.GetRequiredChainLinkWorkloadAndPodLabels(product, testType)
43+
require.NoError(t, err, "Error creating required chain.link labels for workloads and pods")
44+
3645
return &environment.Config{
37-
NamespacePrefix: TestEnvType,
38-
Labels: []string{testSelector},
39-
Test: t,
46+
NamespacePrefix: TestEnvType,
47+
Test: t,
48+
Labels: nsLabels,
49+
WorkloadLabels: workloadPodLabels,
50+
PodLabels: workloadPodLabels,
51+
SkipRequiredChainLinkLabelsValidation: true,
4052
}
4153
}
4254

lib/k8s/environment/environment.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ type Config struct {
129129
detachRunner bool
130130
// fundReturnFailed the status of a fund return
131131
fundReturnFailed bool
132+
// Skip validating that all required chain.link labels are present in the final manifest
133+
SkipRequiredChainLinkLabelsValidation bool
132134
}
133135

134136
func defaultEnvConfig() *Config {
@@ -513,11 +515,13 @@ func (m *Environment) ReplaceHelm(name string, chart ConnectedChart) (*Environme
513515
workloadLabels, err := getComponentLabels(m.Cfg.WorkloadLabels, chart.GetLabels())
514516
if err != nil {
515517
m.err = err
518+
return nil, err
516519
}
517520

518521
podLabels, err := getComponentLabels(m.Cfg.PodLabels, chart.GetLabels())
519522
if err != nil {
520523
m.err = err
524+
return nil, err
521525
}
522526

523527
addRequiredChainLinkLabelsToWorkloads(h, workloadLabels)
@@ -618,7 +622,7 @@ func (m *Environment) UpdateHelm(name string, values map[string]any) (*Environme
618622
return m.ReplaceHelm(name, chart)
619623
}
620624

621-
// AddHelmCharts adds multiple helm charts to the testing environment
625+
// Charts adds multiple helm charts to the testing environment
622626
func (m *Environment) AddHelmCharts(charts []ConnectedChart) *Environment {
623627
if m.err != nil {
624628
return m
@@ -674,11 +678,13 @@ func (m *Environment) AddHelm(chart ConnectedChart) *Environment {
674678
workloadLabels, err := getComponentLabels(m.Cfg.WorkloadLabels, chart.GetLabels())
675679
if err != nil {
676680
m.err = err
681+
return m
677682
}
678683

679684
podLabels, err := getComponentLabels(m.Cfg.PodLabels, chart.GetLabels())
680685
if err != nil {
681686
m.err = err
687+
return m
682688
}
683689
addRequiredChainLinkLabelsToWorkloads(h, workloadLabels)
684690
addDefaultPodAnnotationsAndLabels(h, markNotSafeToEvict(m.Cfg.PreventPodEviction, nil), podLabels)
@@ -865,9 +871,11 @@ func (m *Environment) RunCustomReadyConditions(customCheck *client.ReadyCheckDat
865871
}
866872
log.Debug().Bool("ManifestUpdate", m.Cfg.SkipManifestUpdate).Msg("Update mode")
867873

868-
// make sure all required chain.link labels are present in the final manifest
869-
if err := m.validateRequiredChainLinkLabels(); err != nil {
870-
return err
874+
if !m.Cfg.SkipRequiredChainLinkLabelsValidation {
875+
// make sure all required chain.link labels are present in the final manifest
876+
if err := m.validateRequiredChainLinkLabels(); err != nil {
877+
return err
878+
}
871879
}
872880

873881
if !m.Cfg.SkipManifestUpdate || m.Cfg.JobImage != "" {

lib/k8s/pkg/cdk8s/blockscout/blockscout.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func New(props *Props) func(root cdk8s.Chart) environment.ConnectedChart {
7979
}
8080
vars := vars{
8181
Labels: &map[string]*string{
82-
"app": ptr.Ptr(c.GetName()),
82+
"app": ptr.Ptr(c.GetName()),
83+
"chain.link/component": ptr.Ptr("blockscout"),
8384
},
8485
ConfigMapName: fmt.Sprintf("%s-cm", c.GetName()),
8586
BaseName: c.GetName(),
@@ -117,7 +118,8 @@ type vars struct {
117118
func service(chart cdk8s.Chart, vars vars) {
118119
k8s.NewKubeService(chart, ptr.Ptr(fmt.Sprintf("%s-service", vars.BaseName)), &k8s.KubeServiceProps{
119120
Metadata: &k8s.ObjectMeta{
120-
Name: ptr.Ptr(vars.BaseName),
121+
Name: ptr.Ptr(vars.BaseName),
122+
Labels: vars.Labels,
121123
},
122124
Spec: &k8s.ServiceSpec{
123125
Ports: &[]*k8s.ServicePort{
@@ -173,7 +175,8 @@ func deployment(chart cdk8s.Chart, vars vars) {
173175
ptr.Ptr(fmt.Sprintf("%s-deployment", vars.BaseName)),
174176
&k8s.KubeDeploymentProps{
175177
Metadata: &k8s.ObjectMeta{
176-
Name: ptr.Ptr(vars.BaseName),
178+
Name: ptr.Ptr(vars.BaseName),
179+
Labels: vars.Labels,
177180
},
178181
Spec: &k8s.DeploymentSpec{
179182
Selector: &k8s.LabelSelector{

lib/k8s/pkg/cdk8s/goc/goc.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ func New() func(root cdk8s.Chart) environment.ConnectedChart {
5454
c := &Chart{}
5555
vars := vars{
5656
Labels: &map[string]*string{
57-
"app": ptr.Ptr(c.GetName()),
57+
"app": ptr.Ptr(c.GetName()),
58+
"chain.link/component": ptr.Ptr("goc"),
5859
},
5960
ConfigMapName: fmt.Sprintf("%s-cm", c.GetName()),
6061
BaseName: c.GetName(),
@@ -82,7 +83,8 @@ type vars struct {
8283
func service(chart cdk8s.Chart, vars vars) {
8384
k8s.NewKubeService(chart, ptr.Ptr(fmt.Sprintf("%s-service", vars.BaseName)), &k8s.KubeServiceProps{
8485
Metadata: &k8s.ObjectMeta{
85-
Name: ptr.Ptr(vars.BaseName),
86+
Name: ptr.Ptr(vars.BaseName),
87+
Labels: vars.Labels,
8688
},
8789
Spec: &k8s.ServiceSpec{
8890
Ports: &[]*k8s.ServicePort{
@@ -103,7 +105,8 @@ func deployment(chart cdk8s.Chart, vars vars) {
103105
ptr.Ptr(fmt.Sprintf("%s-deployment", vars.BaseName)),
104106
&k8s.KubeDeploymentProps{
105107
Metadata: &k8s.ObjectMeta{
106-
Name: ptr.Ptr(vars.BaseName),
108+
Name: ptr.Ptr(vars.BaseName),
109+
Labels: vars.Labels,
107110
},
108111
Spec: &k8s.DeploymentSpec{
109112
Selector: &k8s.LabelSelector{

lib/k8s/pkg/cdk8s/http_dummy/dummy.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ func New() func(root cdk8s.Chart) environment.ConnectedChart {
6969
c := &Chart{}
7070
vars := vars{
7171
Labels: &map[string]*string{
72-
"app": ptr.Ptr(c.GetName()),
72+
"app": ptr.Ptr(c.GetName()),
73+
"chain.link/component": ptr.Ptr("http_dummy"),
7374
},
7475
ConfigMapName: fmt.Sprintf("%s-cm", c.GetName()),
7576
BaseName: c.GetName(),
@@ -97,7 +98,8 @@ type vars struct {
9798
func service(chart cdk8s.Chart, vars vars) {
9899
k8s.NewKubeService(chart, ptr.Ptr(fmt.Sprintf("%s-service", vars.BaseName)), &k8s.KubeServiceProps{
99100
Metadata: &k8s.ObjectMeta{
100-
Name: ptr.Ptr(vars.BaseName),
101+
Name: ptr.Ptr(vars.BaseName),
102+
Labels: vars.Labels,
101103
},
102104
Spec: &k8s.ServiceSpec{
103105
Ports: &[]*k8s.ServicePort{
@@ -118,7 +120,8 @@ func deployment(chart cdk8s.Chart, vars vars) {
118120
ptr.Ptr(fmt.Sprintf("%s-deployment", vars.BaseName)),
119121
&k8s.KubeDeploymentProps{
120122
Metadata: &k8s.ObjectMeta{
121-
Name: ptr.Ptr(vars.BaseName),
123+
Name: ptr.Ptr(vars.BaseName),
124+
Labels: vars.Labels,
122125
},
123126
Spec: &k8s.DeploymentSpec{
124127
Selector: &k8s.LabelSelector{

0 commit comments

Comments
 (0)