Skip to content

Commit 3c5e76a

Browse files
authored
Example minimal pipeline for smoke/load/chaos + Pumba chaos tool wrapper (#1301)
* golden tests + Pumba chaos wrapper
1 parent d585ea8 commit 3c5e76a

File tree

38 files changed

+3518
-2703
lines changed

38 files changed

+3518
-2703
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Framework Golden Tests Examples
2+
on:
3+
push:
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}-framework-golden-examples
6+
cancel-in-progress: true
7+
8+
jobs:
9+
test:
10+
defaults:
11+
run:
12+
working-directory: framework/examples/myproject
13+
env:
14+
LOKI_TENANT_ID: promtail
15+
LOKI_URL: http://localhost:3030/loki/api/v1/push
16+
runs-on: ubuntu-latest
17+
permissions:
18+
id-token: write
19+
contents: read
20+
strategy:
21+
matrix:
22+
test:
23+
- name: TestSmoke
24+
config: smoke.toml
25+
count: 1
26+
timeout: 10m
27+
- name: TestLoad
28+
config: load.toml
29+
count: 1
30+
timeout: 10m
31+
- name: TestChaos
32+
config: chaos.toml
33+
count: 1
34+
timeout: 10m
35+
steps:
36+
- name: Checkout repo
37+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
38+
- name: Configure AWS credentials using OIDC
39+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
40+
with:
41+
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
42+
aws-region: us-east-1
43+
- name: Authenticate to ECR Public
44+
id: login-ecr-public
45+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
46+
with:
47+
registry-type: public
48+
- name: Check for changes in Framework
49+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
50+
id: changes
51+
with:
52+
filters: |
53+
src:
54+
- 'framework/**'
55+
- name: Set up Go
56+
uses: actions/setup-go@v4
57+
with:
58+
go-version: 1.22.8
59+
- name: Cache Go modules
60+
uses: actions/cache@v3
61+
with:
62+
path: |
63+
~/.cache/go-build
64+
~/go/pkg/mod
65+
key: go-modules-${{ hashFiles('**/go.sum') }}-${{ runner.os }}-framework-golden-examples
66+
restore-keys: |
67+
go-modules-${{ hashFiles('**/go.sum') }}-${{ runner.os }}-framework-golden-examples
68+
- name: Install dependencies
69+
run: go mod download
70+
- name: Run Docker Component Tests
71+
if: steps.changes.outputs.src == 'true'
72+
env:
73+
CTF_CONFIGS: ${{ matrix.test.config }}
74+
run: |
75+
go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }}

.github/workflows/framework.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ jobs:
1010
run:
1111
working-directory: framework
1212
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
1316
steps:
1417
- name: Checkout repo
1518
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
19+
- name: Configure AWS credentials using OIDC
20+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
21+
with:
22+
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
23+
aws-region: us-east-1
24+
- name: Authenticate to ECR Public
25+
id: login-ecr-public
26+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
27+
with:
28+
registry-type: public
1629
- name: Check for changes in Framework
1730
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
1831
id: changes

book/src/SUMMARY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
- [Chainlink]()
3737
- [RPC]()
3838
- [Loki]()
39+
- [Testing]()
40+
- [Smoke]()
41+
- [Performance]()
42+
- [Chaos]()
3943
- [Interactive](framework/interactive.md)
4044
- [Continuous Integration](ci/ci.md)
4145
- [Libraries](./libraries.md)

book/src/testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Testing

book/src/testing/chaos.md

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

book/src/testing/performance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Performance

book/src/testing/smoke.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Smoke

framework/.changeset/v0.1.10.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Move all deployments to static ports
2+
- Add example smoke/load/chaos pipelines (WIP)
3+
- Add Pumba chaos tool

framework/chaos/chaos.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package chaos
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/docker/docker/api/types/container"
7+
"github.com/docker/docker/api/types/mount"
8+
"github.com/google/uuid"
9+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
10+
"github.com/testcontainers/testcontainers-go"
11+
"strings"
12+
)
13+
14+
func ExecPumba(command string) (func(), error) {
15+
ctx := context.Background()
16+
cmd := strings.Split(command, " ")
17+
pumbaReq := testcontainers.ContainerRequest{
18+
Name: fmt.Sprintf("chaos-%s", uuid.NewString()[0:5]),
19+
Image: "gaiaadm/pumba",
20+
Labels: framework.DefaultTCLabels(),
21+
Privileged: true,
22+
Cmd: cmd,
23+
HostConfigModifier: func(h *container.HostConfig) {
24+
h.Mounts = []mount.Mount{
25+
{
26+
Type: "bind",
27+
Source: "/var/run/docker.sock",
28+
Target: "/var/run/docker.sock",
29+
ReadOnly: true,
30+
},
31+
}
32+
},
33+
}
34+
pumbaContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
35+
ContainerRequest: pumbaReq,
36+
Started: true,
37+
})
38+
if err != nil {
39+
return nil, fmt.Errorf("failed to start pumba chaos container: %w", err)
40+
}
41+
framework.L.Info().Msg("Pumba chaos started")
42+
return func() {
43+
_ = pumbaContainer.Terminate(ctx)
44+
}, nil
45+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# # config file version
2+
apiVersion: 1
3+
4+
providers:
5+
- name: 'WASP'
6+
orgId: 1
7+
folder: 'Load testing'
8+
folderUid: ''
9+
type: file
10+
disableDeletion: false
11+
updateIntervalSeconds: 10
12+
allowUiUpdates: false
13+
options:
14+
path: /var/lib/grafana/dashboards
15+
foldersFromFilesStructure: true

0 commit comments

Comments
 (0)