@@ -30,9 +30,29 @@ This documentation is outdated, and we are using it only internally to run our s
3030
3131## Getting started
3232
33- Read [ here] ( KUBERNETES.md ) about how to spin up a local cluster if you don't have one
33+ Read [ here] ( KUBERNETES.md ) about how to spin up a local cluster if you don't have one.
3434
35- Let's create a simple environment by combining different deployment parts
35+ Following examples will use hardcoded ` chain.link ` labels for the sake of satisfying validations. When using any of remote clusters you should
36+ provide them with actual and valid values, for example using following convenience functions:
37+ ``` go
38+ nsLabels , err := GetRequiredChainLinkNamespaceLabels (" my-product" , " load" )
39+ require.NoError (t, err, " Error creating required chain.link labels for namespace" )
40+
41+ workloadPodLabels , err := GetRequiredChainLinkWorkloadAndPodLabels (" my-product" , " load" )
42+ require.NoError (t, err, " Error creating required chain.link labels for workloads and pods" )
43+ ```
44+
45+ And then setting them in the ` Environment ` config:
46+ ``` go
47+ envConfig := &environment.Config {
48+ Labels : nsLabels,
49+ WorkloadLabels : workloadPodLabels
50+ PodLabels : workloadPodLabels
51+ NamespacePrefix : " new-environment" ,
52+ }
53+ ```
54+
55+ Now, let's create a simple environment by combining different deployment parts.
3656
3757Create ` examples/simple/env.go `
3858
@@ -48,14 +68,21 @@ import (
4868 " github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver"
4969)
5070
71+ func addHardcodedLabelsToEnv (env *environment .Config ) {
72+ env.Labels = []string {" chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" }
73+ env.WorkloadLabels = map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" }
74+ env.PodLabels = map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" }
75+ }
76+
5177func main () {
52- err := environment.New (&environment.Config {
53- KeepConnection: false ,
54- RemoveOnInterrupt: false ,
55- Labels: []string {" chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" },
56- WorkloadLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
57- PodLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
58- }).
78+ env := &environment.Config {
79+ NamespacePrefix: " new-environment" ,
80+ KeepConnection: false ,
81+ RemoveOnInterrupt: false ,
82+ }
83+
84+ addHardcodedLabelsToEnv (env)
85+ err := environment.New (env).
5986 AddHelm (ethereum.New (nil )).
6087 AddHelm (chainlink.New (0 , nil )).
6188 Run ()
@@ -104,21 +131,14 @@ import (
104131)
105132
106133func main () {
107- nsLabels , err := GetRequiredChainLinkNamespaceLabels (" my-product" , " load" )
108- require.NoError (t, err, " Error creating required chain.link labels for namespace" )
109-
110- workloadPodLabels , err := GetRequiredChainLinkWorkloadAndPodLabels (" my-product" , " load" )
111- require.NoError (t, err, " Error creating required chain.link labels for workloads and pods" )
112-
113- nsLabels := append (nsLabel,s " type=construction-in-progress" )
114- err := environment.New (&environment.Config {
115- Labels: nsLabels,
116- WorkloadLabels: workloadPodLabels
117- PodLabels: workloadPodLabels
134+ env := &environment.Config {
118135 NamespacePrefix: " new-environment" ,
119136 KeepConnection: true ,
120137 RemoveOnInterrupt: true ,
121- }).
138+ }
139+
140+ addHardcodedLabelsToEnv (env)
141+ err := environment.New (env).
122142 AddHelm (ethereum.New (nil )).
123143 AddHelm (chainlink.New (0 , nil )).
124144 Run ()
@@ -193,15 +213,15 @@ import (
193213)
194214
195215func main () {
196- e := environment.New (&environment.Config {
197- Labels: []string {" chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" },
198- WorkloadLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
199- PodLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
216+ env := &environment.Config {
200217 NamespacePrefix: " adding-new-deployment-part" ,
201218 TTL: 3 * time.Hour ,
202219 KeepConnection: true ,
203220 RemoveOnInterrupt: true ,
204- }).
221+ }
222+
223+ addHardcodedLabelsToEnv (env)
224+ e := environment.New (env).
205225 AddHelm (deployment_part.New (nil )).
206226 AddHelm (chainlink.New (0 , map [string ]any{
207227 " replicas" : 5 ,
@@ -249,7 +269,7 @@ type ConnectedChart interface {
249269 // ExportData export deployment part data in the env
250270 ExportData (e *Environment) error
251271 // GetLabels get labels for component, it must return `chain.link/component` label
252- GetLabels () map [string ]string
272+ GetLabels () map [string ]string
253273}
254274```
255275
@@ -266,16 +286,24 @@ import (
266286)
267287
268288func main () {
269- e := environment.New (nil ).
270- AddChart (deployment_part_cdk8s.New (&deployment_part_cdk8s.Props {})).
271- AddHelm (ethereum.New (nil )).
272- AddHelm (chainlink.New (0 , map [string ]any{
273- " replicas" : 2 ,
274- }))
275- if err := e.Run (); err != nil {
276- panic (err)
277- }
278- e.Shutdown ()
289+ env := &environment.Config {
290+ NamespacePrefix: " adding-new-deployment-part" ,
291+ TTL: 3 * time.Hour ,
292+ KeepConnection: true ,
293+ RemoveOnInterrupt: true ,
294+ }
295+
296+ addHardcodedLabelsToEnv (env)
297+ e := environment.New (env).
298+ AddChart (deployment_part_cdk8s.New (&deployment_part_cdk8s.Props {})).
299+ AddHelm (ethereum.New (nil )).
300+ AddHelm (chainlink.New (0 , map [string ]any{
301+ " replicas" : 2 ,
302+ }))
303+ if err := e.Run (); err != nil {
304+ panic (err)
305+ }
306+ e.Shutdown ()
279307}
280308```
281309
@@ -411,10 +439,9 @@ import (
411439func main () {
412440 modifiedEnvConfig := &environment.Config {
413441 NamespacePrefix: " modified-env" ,
414- Labels: []string {" envType=Modified" , " chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" },
415- WorkloadLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
416- PodLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" }
417442 }
443+
444+ addHardcodedLabelsToEnv (modifiedEnvConfig)
418445 e := environment.New (modifiedEnvConfig).
419446 AddHelm (mockservercfg.New (nil )).
420447 AddHelm (mockserver.New (nil )).
@@ -470,7 +497,7 @@ const (
470497
471498 EnvVarTeam = " CHAINLINK_USER_TEAM"
472499 EnvVarTeamDescription = " Team to, which owner of the environment belongs to"
473- EnvVarTeamExample = " BIX, CCIP, BCM"
500+ EnvVarTeamExample = " BIX, CCIP, BCM"
474501
475502 EnvVarCLCommitSha = " CHAINLINK_COMMIT_SHA"
476503 EnvVarCLCommitShaDescription = " The sha of the commit that you're running tests on. Mostly used for CI"
@@ -542,7 +569,7 @@ type Config struct {
542569 RemoveOnInterrupt bool
543570 // UpdateWaitInterval an interval to wait for deployment update started
544571 UpdateWaitInterval time.Duration
545-
572+
546573 // Remote Runner Specific Variables //
547574 // JobImage an image to run environment as a job inside k8s
548575 JobImage string
@@ -579,11 +606,10 @@ import (
579606)
580607
581608func main () {
582- e := environment.New (&environment.Config {
583- Labels: []string {" chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" },
584- WorkloadLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
585- PodLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" }
586- }).
609+ env := &environment.Config {}
610+
611+ addHardcodedLabelsToEnv (env)
612+ e := environment.New (env).
587613 AddHelm (ethereum.New (nil )).
588614 AddHelm (chainlink.New (0 , nil ))
589615 if err := e.Run (); err != nil {
@@ -612,11 +638,10 @@ import (
612638)
613639
614640func main () {
615- e := environment.New (&environment.Config {
616- Labels: []string {fmt.Sprintf (" envType=%s " , pkg.EnvTypeEVM5 ), " chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" },
617- WorkloadLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
618- PodLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" }
619- }).
641+ env := &environment.Config {}
642+ addHardcodedLabelsToEnv (env)
643+
644+ e := environment.New (env).
620645 AddHelm (ethereum.New (nil )).
621646 AddHelm (chainlink.New (0 , nil ))
622647 err := e.Run ()
@@ -667,26 +692,23 @@ import (
667692)
668693
669694func main () {
670- envConfig := &environment.Config {
671- Labels: []string {" chain.link/product=myProduct" , " chain.link/team=my-team" , " chain.link/cost-center=test-tooling-load-test" },
672- WorkloadLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" },
673- PodLabels: map [string ]string {" chain.link/product" : " myProduct" , " chain.link/team" : " my-team" , " chain.link/cost-center" : " test-tooling-load-test" }
674- }
675- e := environment.New (envConfig).
676- AddChart (goc.New ()).
677- AddChart (dummy.New ())
678- if err := e.Run (); err != nil {
679- panic (err)
680- }
681- // run your test logic here
682- time.Sleep (1 * time.Minute )
683- if err := e.SaveCoverage (); err != nil {
684- panic (err)
685- }
686- // clear the coverage, rerun the tests again if needed
687- if err := e.ClearCoverage (); err != nil {
688- panic (err)
689- }
695+ envConfig := &environment.Config {}
696+ addHardcodedLabelsToEnv (envConfig)
697+ e := environment.New (envConfig).
698+ AddChart (goc.New ()).
699+ AddChart (dummy.New ())
700+ if err := e.Run (); err != nil {
701+ panic (err)
702+ }
703+ // run your test logic here
704+ time.Sleep (1 * time.Minute )
705+ if err := e.SaveCoverage (); err != nil {
706+ panic (err)
707+ }
708+ // clear the coverage, rerun the tests again if needed
709+ if err := e.ClearCoverage (); err != nil {
710+ panic (err)
711+ }
690712}
691713
692714```
0 commit comments