-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCRv1 CRIB smoke + chaos test (#13778)
* quick OCRv1 CRIB test (WIP) * test default static CRIB config * try to deploy a new CRIB * add nix step * CRIB chaos test * CRIB chaos test * use full reboot * bump deps * comment CI * goimports * readme * simplify nodes check
- Loading branch information
Showing
12 changed files
with
292 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# this is disabled because of GAP limitations, should be re-enabled when github-actions-controller will be installed | ||
|
||
#name: CRIB Integration Tests | ||
#on: | ||
# push: | ||
# workflow_call: | ||
#concurrency: | ||
# group: ${{ github.workflow }}-${{ github.ref }} | ||
# cancel-in-progress: true | ||
#jobs: | ||
# test: | ||
# runs-on: ubuntu-latest | ||
# environment: integration | ||
# permissions: | ||
# id-token: write | ||
# contents: read | ||
# actions: read | ||
# steps: | ||
# - name: Checkout repository | ||
# uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
# | ||
# - name: Setup Nix + GATI environment | ||
# uses: smartcontractkit/.github/actions/setup-nix-gati@514fe346780e2eddf7ea8b9f48120c2fba120d94 | ||
# with: | ||
# aws-role-arn: ${{ secrets.AWS_OIDC_CHAINLINK_AUTO_PR_TOKEN_ISSUER_ROLE_ARN }} | ||
# aws-lambda-url: ${{ secrets.AWS_CORE_TOKEN_ISSUER_LAMBDA_URL }} # see https://github.com/smartcontractkit/ infra/blob/a79bcfb48315c4411023c182e98eb80ff9e9cda6/accounts/production/us-west-2/lambda/ github-app-token-issuer-production/teams/releng/config.json#L9 | ||
# aws-region: ${{ secrets.AWS_REGION }} | ||
# aws-role-duration-seconds: ${{ secrets.AWS_ROLE_DURATION_SECONDS }} | ||
# enable-magic-cache: true | ||
# | ||
# - name: Nix Develop Action | ||
# uses: nicknovitski/nix-develop@v1 | ||
# with: | ||
# arguments: "--accept-flake-config" | ||
# - name: setup-gap | ||
# uses: smartcontractkit/.github/actions/setup-gap@d316f66b2990ea4daa479daa3de6fc92b00f863e # [email protected] | ||
# with: | ||
# aws-role-arn: ${{ secrets.AWS_OIDC_CRIB_ROLE_ARN_STAGE }} | ||
# api-gateway-host: ${{ secrets.AWS_API_GW_HOST_K8S_STAGE }} | ||
# aws-region: ${{ secrets.AWS_REGION }} | ||
# ecr-private-registry: ${{ secrets.AWS_ACCOUNT_ID_PROD }} | ||
# k8s-cluster-name: ${{ secrets.AWS_K8S_CLUSTER_NAME_STAGE }} | ||
# use-private-ecr-registry: true | ||
# use-k8s: true | ||
# metrics-job-name: "k8s" | ||
# gc-basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} | ||
# gc-host: ${{ secrets.GRAFANA_INTERNAL_HOST }} | ||
# gc-org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} | ||
# - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
# name: Checkout CRIB repository | ||
# with: | ||
# repository: 'smartcontractkit/crib' | ||
# ref: 'main' | ||
# - name: Generate Short UUID | ||
# id: uuid | ||
# run: echo "CRIB_NAMESPACE=$(uuidgen | cut -c1-5)" >> $GITHUB_ENV | ||
# - name: Create a new CRIB environment | ||
# run: |- | ||
# devspace use namespace $CRIB_NAMESPACE | ||
# devspace deploy --profile local-dev-simulated-core-ocr1 | ||
# - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
# - name: Setup go | ||
# uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
# with: | ||
# go-version-file: "go.mod" | ||
# - name: Run CRIB integration test | ||
# working-directory: integration-tests/crib | ||
# env: | ||
# K8S_STAGING_INGRESS_SUFFIX: ${{ secrets.K8S_STAGING_INGRESS_SUFFIX }} | ||
# CRIB_NAMESPACE: ${{ env.CRIB_NAMESPACE }} | ||
# CRIB_NETWORK: geth | ||
# CRIB_NODES: 5 | ||
# run: |- | ||
# go test -v -run TestCRIB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### CRIB Health Check Test | ||
|
||
## Setup CRIB | ||
This is a simple smoke + chaos test for CRIB deployment. | ||
It runs OCRv1 and reboots the environment confirming integration with environment is working and data is properly saved even after reboots. | ||
Go to the [CRIB](https://github.com/smartcontractkit/crib) repository and spin up a cluster. | ||
|
||
```shell | ||
./scripts/cribbit.sh crib-oh-my-crib | ||
devspace deploy --debug --profile local-dev-simulated-core-ocr1 | ||
``` | ||
|
||
## Run the tests | ||
```shell | ||
CRIB_NAMESPACE=crib-oh-my-crib | ||
CRIB_NETWORK=geth # only "geth" is supported for now | ||
CRIB_NODES=5 # min 5 nodes | ||
go test -v -run TestCRIB | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package crib | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/chaos-mesh/chaos-mesh/api/v1alpha1" | ||
"github.com/smartcontractkit/havoc/k8schaos" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func rebootCLNamespace(delay time.Duration, namespace string) (*k8schaos.Chaos, error) { | ||
k8sClient, err := k8schaos.NewChaosMeshClient() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return k8schaos.NewChaos(k8schaos.ChaosOpts{ | ||
Description: "Reboot CRIB", | ||
DelayCreate: delay, | ||
Object: &v1alpha1.PodChaos{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "PodChaos", | ||
APIVersion: "chaos-mesh.org/v1alpha1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "reboot-crib", | ||
Namespace: namespace, | ||
}, | ||
Spec: v1alpha1.PodChaosSpec{ | ||
ContainerSelector: v1alpha1.ContainerSelector{ | ||
PodSelector: v1alpha1.PodSelector{ | ||
Mode: v1alpha1.AllMode, | ||
Selector: v1alpha1.PodSelectorSpec{ | ||
GenericSelectorSpec: v1alpha1.GenericSelectorSpec{ | ||
Namespaces: []string{namespace}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Action: v1alpha1.PodKillAction, | ||
}, | ||
}, | ||
Client: k8sClient, | ||
Logger: &k8schaos.Logger, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package crib | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/smartcontractkit/havoc/k8schaos" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/smartcontractkit/chainlink/integration-tests/actions" | ||
"github.com/smartcontractkit/chainlink/integration-tests/contracts" | ||
|
||
"github.com/smartcontractkit/chainlink-testing-framework/logging" | ||
) | ||
|
||
func TestCRIB(t *testing.T) { | ||
l := logging.GetTestLogger(t) | ||
|
||
sethClient, msClient, bootstrapNode, workerNodes, err := ConnectRemote() | ||
require.NoError(t, err) | ||
|
||
lta, err := actions.SetupOCRv1Cluster(l, sethClient, workerNodes) | ||
require.NoError(t, err) | ||
ocrInstances, err := actions.SetupOCRv1Feed(l, sethClient, lta, msClient, bootstrapNode, workerNodes) | ||
require.NoError(t, err) | ||
|
||
err = actions.SetAllAdapterResponsesToTheSameValue(10, ocrInstances, workerNodes, msClient) | ||
require.NoError(t, err) | ||
actions.SimulateOCRv1EAActivity(l, 3*time.Second, ocrInstances, workerNodes, msClient) | ||
|
||
err = actions.WatchNewOCRRound(l, sethClient, 1, contracts.V1OffChainAgrregatorToOffChainAggregatorWithRounds(ocrInstances), 5*time.Minute) | ||
require.NoError(t, err, "Error watching for new OCR round") | ||
|
||
ch, err := rebootCLNamespace( | ||
1*time.Second, | ||
os.Getenv("CRIB_NAMESPACE"), | ||
) | ||
ch.Create(context.Background()) | ||
ch.AddListener(k8schaos.NewChaosLogger(l)) | ||
t.Cleanup(func() { | ||
err := ch.Delete(context.Background()) | ||
require.NoError(t, err) | ||
}) | ||
require.Eventually(t, func() bool { | ||
err = actions.WatchNewOCRRound(l, sethClient, 3, contracts.V1OffChainAgrregatorToOffChainAggregatorWithRounds(ocrInstances), 5*time.Minute) | ||
if err != nil { | ||
l.Info().Err(err).Msg("OCR round is not there yet") | ||
return false | ||
} | ||
return true | ||
}, 3*time.Minute, 5*time.Second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.