Skip to content

Commit a8cb24f

Browse files
Merge branch 'main' into chore/add_eth_feed_id_env_var
2 parents d18093e + c5f25e8 commit a8cb24f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2308
-1344
lines changed

.github/workflows/linters.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
- parrot
1414
- wasp
1515
- seth
16-
- havoc
1716
- k8s-test-runner
1817
- lib
1918
- tools/workflowresultparser

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [CLI](./framework/cli.md)
1313
- [Configuration](./framework/configuration.md)
1414
- [Debugging Tests](framework/components/debug.md)
15+
- [Generating Tests](framework/generate.md)
1516
- [Creating your own components](./developing/developing_components.md)
1617
- [Exposing Components](framework/components/state.md)
1718
- [Asserting Logs](./developing/asserting_logs.md)

book/src/framework/components/blockchains/solana.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Since `Solana` doesn't have official image for `arm64` we built it, images we use are:
44
```
5-
amd64 solanalabs/solana:v1.18.26 - used in CI
6-
arm64 f4hrenh9it/solana:latest - used locally
5+
amd64 solanalabs/solana:v1.18.26
6+
arm64 public.ecr.aws/w0i8p0z9/solana-validator:main-1dcdbc4
77
```
88

99
## Configuration

book/src/framework/generate.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Generating Tests
2+
3+
Some types of tests may require a lot of boilerplate and configurability, for example load and chaos tests.
4+
5+
We provide code generation tool that help you to start with best practes in such cases.
6+
7+
All generators have `-h` or `--help` flag, please read the docs!

framework/.changeset/v0.11.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Updated solana image selection logic to use runtime arch

framework/.changeset/v0.11.8.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Usnet Docker Build Ctx and Filepath if `CTF_*_IMAGE` env vars are used

framework/.changeset/v0.11.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Chaos and Load codegen

framework/cmd/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ blockscout/services/blockscout-db-data
22
blockscout/services/logs
33
blockscout/services/redis-data
44
blockscout/services/stats-db-data
5+
wasp-self-test/
6+
wasp-test/

framework/cmd/main.go

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/urfave/cli/v2"
1212

1313
"github.com/smartcontractkit/chainlink-testing-framework/framework"
14+
"github.com/smartcontractkit/chainlink-testing-framework/wasp"
1415
)
1516

1617
func main() {
@@ -19,6 +20,127 @@ func main() {
1920
Usage: "Chainlink Testing Framework CLI",
2021
UsageText: "'ctf' is a useful utility that can:\n- clean up test docker containers\n- modify test files\n- create a local observability stack with Grafana/Loki/Pyroscope",
2122
Commands: []*cli.Command{
23+
{
24+
Name: "gen",
25+
Aliases: []string{"g"},
26+
Usage: "Generates various test templates",
27+
Subcommands: []*cli.Command{
28+
{
29+
Name: "load",
30+
Aliases: []string{"l"},
31+
Usage: "Generates a load/chaos test template for Kubernetes namespace",
32+
Description: `Scans a Kubernetes namespace and generates load testing templates for discovered services.
33+
34+
Prerequisites:
35+
36+
Connect to K8s and don't forget to switch context first:
37+
kubectl config use-context <your_ctx>
38+
By default test sends data to a local CTF stack, see //TODO comments to change that, spin up the stack:
39+
ctf obs up
40+
41+
Usage:
42+
43+
Generate basic kill/latency tests:
44+
ctf gen k8s-load my-namespace
45+
With workload:
46+
ctf gen k8s-load -w my-namespace
47+
With workload and name:
48+
ctf gen k8s-load -w -n TestSomething my-namespace
49+
50+
Be aware that any TODO requires your attention before your run the final test!
51+
`,
52+
ArgsUsage: "--workload --name $name --output-dir $dir --module $go_mod_name [NAMESPACE]",
53+
Flags: []cli.Flag{
54+
&cli.StringFlag{
55+
Name: "name",
56+
Aliases: []string{"n"},
57+
Value: "TestGeneratedLoadChaos",
58+
Usage: "Test suite name",
59+
},
60+
&cli.StringFlag{
61+
Name: "output-dir",
62+
Aliases: []string{"o"},
63+
Value: "wasp-test",
64+
Usage: "Output directory for generated files",
65+
},
66+
&cli.StringFlag{
67+
Name: "module",
68+
Aliases: []string{"m"},
69+
Value: "github.com/smartcontractkit/chainlink-testing-framework/wasp-test",
70+
Usage: "Go module name for generated project",
71+
},
72+
&cli.BoolFlag{
73+
Name: "workload",
74+
Aliases: []string{"w"},
75+
Value: false,
76+
Usage: "Include workload generation in tests",
77+
},
78+
&cli.StringFlag{
79+
Name: "pod-label-key",
80+
Aliases: []string{"k"},
81+
Value: "app.kubernetes.io/instance",
82+
Usage: "Default unique pod key, read more here: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/",
83+
},
84+
&cli.StringFlag{
85+
Name: "latency-ms",
86+
Aliases: []string{"l"},
87+
Value: "300",
88+
Usage: "Default latency for delay experiments in milliseconds",
89+
},
90+
&cli.StringFlag{
91+
Name: "jitter-ms",
92+
Aliases: []string{"j"},
93+
Value: "100",
94+
Usage: "Default jitter for delay experiments in milliseconds",
95+
},
96+
},
97+
Action: func(c *cli.Context) error {
98+
if c.Args().Len() == 0 {
99+
return fmt.Errorf("Kubernetes namespace argument is required")
100+
}
101+
ns := c.Args().First()
102+
testSuiteName := c.String("name")
103+
podLabelKey := c.String("pod-label-key")
104+
latencyMs := c.Int("latency-ms")
105+
jitterMs := c.Int("jitter-ms")
106+
outputDir := c.String("output-dir")
107+
moduleName := c.String("module")
108+
includeWorkload := c.Bool("workload")
109+
framework.L.Info().
110+
Str("SuiteName", testSuiteName).
111+
Str("OutputDir", outputDir).
112+
Str("GoModuleName", moduleName).
113+
Bool("Workload", includeWorkload).
114+
Msg("Generating load&chaos test template")
115+
116+
k8sClient, err := wasp.NewK8s()
117+
if err != nil {
118+
return fmt.Errorf("failed to create K8s client")
119+
}
120+
121+
cg, err := wasp.NewLoadTestGenBuilder(k8sClient, ns).
122+
TestSuiteName(testSuiteName).
123+
UniqPodLabelKey(podLabelKey).
124+
Latency(latencyMs).
125+
Jitter(jitterMs).
126+
Workload(includeWorkload).
127+
OutputDir(outputDir).
128+
GoModName(moduleName).
129+
Build()
130+
if err != nil {
131+
return fmt.Errorf("failed to create codegen: %w", err)
132+
}
133+
if err := cg.Read(); err != nil {
134+
return fmt.Errorf("failed to scan namespace: %w", err)
135+
}
136+
if err := cg.Write(); err != nil {
137+
return fmt.Errorf("failed to generate module: %w", err)
138+
}
139+
return nil
140+
},
141+
},
142+
},
143+
},
22144
{
23145
Name: "config",
24146
Aliases: []string{"c"},
@@ -206,7 +328,7 @@ func PrettyPrintTOML(inputFile string, outputFile string) error {
206328
}
207329

208330
//nolint
209-
err = os.WriteFile(outputFile, []byte(dumpData), 0644)
331+
err = os.WriteFile(outputFile, []byte(dumpData), 0o644)
210332
if err != nil {
211333
return fmt.Errorf("error writing to output file: %v", err)
212334
}

framework/components/blockchain/solana.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"runtime"
89
"strconv"
910
"strings"
1011
"time"
@@ -31,12 +32,13 @@ var idJSONRaw = `
3132
`
3233

3334
func defaultSolana(in *Input) {
34-
ci := os.Getenv("CI") == "true"
35-
if in.Image == "" && !ci {
36-
in.Image = "f4hrenh9it/solana"
37-
}
38-
if in.Image == "" && ci {
39-
in.Image = "anzaxyz/agave:v2.1.13"
35+
if in.Image == "" {
36+
// Official arm64 image does not exist for Solana so use custom built one
37+
if runtime.GOARCH == "arm64" {
38+
in.Image = "public.ecr.aws/w0i8p0z9/solana-validator:main-1dcdbc4"
39+
} else {
40+
in.Image = "anzaxyz/agave:v2.1.13"
41+
}
4042
}
4143
if in.Port == "" {
4244
in.Port = "8999"

0 commit comments

Comments
 (0)