Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example minimal pipeline for smoke/load/chaos + Pumba chaos tool wrapper #1301

Merged
merged 16 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/framework-golden-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Framework Golden Tests Examples
on:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-framework-golden-examples
cancel-in-progress: true

jobs:
test:
defaults:
run:
working-directory: framework/examples/myproject
env:
LOKI_TENANT_ID: promtail
LOKI_URL: http://localhost:3030/loki/api/v1/push
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
strategy:
matrix:
test:
- name: TestSmoke
config: smoke.toml
count: 1
timeout: 10m
- name: TestLoad
config: load.toml
count: 1
timeout: 10m
- name: TestChaos
config: chaos.toml
count: 1
timeout: 10m
steps:
- name: Checkout repo
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Configure AWS credentials using OIDC
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
aws-region: us-east-1
- name: Authenticate to ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Check for changes in Framework
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
filters: |
src:
- 'framework/**'
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.8
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-modules-${{ hashFiles('**/go.sum') }}-${{ runner.os }}-framework-golden-examples
restore-keys: |
go-modules-${{ hashFiles('**/go.sum') }}-${{ runner.os }}-framework-golden-examples
- name: Install dependencies
run: go mod download
- name: Run Docker Component Tests
if: steps.changes.outputs.src == 'true'
env:
CTF_CONFIGS: ${{ matrix.test.config }}
run: |
go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }}
13 changes: 13 additions & 0 deletions .github/workflows/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ jobs:
run:
working-directory: framework
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Configure AWS credentials using OIDC
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
aws-region: us-east-1
- name: Authenticate to ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Check for changes in Framework
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
Expand Down
4 changes: 4 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
- [Chainlink]()
- [RPC]()
- [Loki]()
- [Testing]()
- [Smoke]()
- [Performance]()
- [Chaos]()
- [Interactive](framework/interactive.md)
- [Continuous Integration](ci/ci.md)
- [Libraries](./libraries.md)
Expand Down
1 change: 1 addition & 0 deletions book/src/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Testing
1 change: 1 addition & 0 deletions book/src/testing/chaos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Chaos
1 change: 1 addition & 0 deletions book/src/testing/performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Performance
1 change: 1 addition & 0 deletions book/src/testing/smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Smoke
3 changes: 3 additions & 0 deletions framework/.changeset/v0.1.10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Move all deployments to static ports
- Add example smoke/load/chaos pipelines (WIP)
- Add Pumba chaos tool
45 changes: 45 additions & 0 deletions framework/chaos/chaos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package chaos

import (
"context"
"fmt"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/google/uuid"
"github.com/smartcontractkit/chainlink-testing-framework/framework"
"github.com/testcontainers/testcontainers-go"
"strings"
)

func ExecPumba(command string) (func(), error) {
ctx := context.Background()
cmd := strings.Split(command, " ")
pumbaReq := testcontainers.ContainerRequest{
Name: fmt.Sprintf("chaos-%s", uuid.NewString()[0:5]),
Image: "gaiaadm/pumba",
Labels: framework.DefaultTCLabels(),
Privileged: true,
Cmd: cmd,
HostConfigModifier: func(h *container.HostConfig) {
h.Mounts = []mount.Mount{
{
Type: "bind",
Source: "/var/run/docker.sock",
Target: "/var/run/docker.sock",
ReadOnly: true,
},
}
},
}
pumbaContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: pumbaReq,
Started: true,
})
if err != nil {
return nil, fmt.Errorf("failed to start pumba chaos container: %w", err)
}
framework.L.Info().Msg("Pumba chaos started")
return func() {
_ = pumbaContainer.Terminate(ctx)
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# # config file version
apiVersion: 1

providers:
- name: 'WASP'
orgId: 1
folder: 'Load testing'
folderUid: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: false
options:
path: /var/lib/grafana/dashboards
foldersFromFilesStructure: true

This file was deleted.

Loading
Loading