Skip to content

Commit

Permalink
Move old docs, add deprecation notice (#1284)
Browse files Browse the repository at this point in the history
move v1 docs to mdbook, stub old readmes and point them all in one place
  • Loading branch information
skudasov authored Oct 31, 2024
1 parent 7437e46 commit d4379fc
Show file tree
Hide file tree
Showing 34 changed files with 1,122 additions and 2,388 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-go-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ jobs:
goarch: ${{ matrix.goarch }}
binary_name: ${{ env.PACKAGE_NAME }}
release_name: ${{ env.PACKAGE_NAME }}
release_tag: ${{ env.PACKAGE_NAME}}-${{ env.VERSION }}
release_tag: ${{ env.PACKAGE_NAME}}/${{ env.VERSION }}
project_path: ${{ env.PACKAGE_NAME }}/cmd
asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.goarch }}
52 changes: 0 additions & 52 deletions RELEASE.md

This file was deleted.

24 changes: 0 additions & 24 deletions SECRETS.md

This file was deleted.

11 changes: 11 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [CLI](./framework/cli.md)
- [Configuration](./framework/configuration.md)
- [Test Configuration](./framework/test_configuration_overrides.md)
- [Caching](framework/components/caching.md)
- [Secrets]()
- [Observability Stack](framework/observability/observability_stack.md)
- [Metrics]()
Expand All @@ -34,16 +35,26 @@
- [Chainlink]()
- [RPC]()
- [Loki]()
- [Continuous Integration](ci/ci.md)
- [Libraries](./libraries.md)
- [Seth](./libs/seth.md)
- [WASP](./libs/wasp.md)
- [Havoc](./libs/havoc.md)
- [K8s Test Runner](k8s-test-runner/k8s-test-runner.md)

---

- [Developing](developing.md)
- [Components](developing/developing_components.md)
- [Releasing modules](releasing_modules.md)

---
- [Lib (*Deprecated*)](lib.md)
- [Blockchain](lib/blockchain.md)
- [Kubernetes](lib/k8s/KUBERNETES.md)
- [K8s Remote Run](lib/k8s/REMOTE_RUN.md)
- [K8s Tutorial](lib/k8s/TUTORIAL.md)
- [Config](lib/config/config.md)
- [CRIB Connector](lib/crib.md)
---
- [Build info](build_info.md)
5 changes: 5 additions & 0 deletions book/src/ci/ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Continuous Integration

Here we describe our good practices for structuring different types of tests in Continuous Integration (GitHub Actions).

Follow [this](https://github.com/smartcontractkit/.github/tree/main/.github/workflows) guide.
6 changes: 3 additions & 3 deletions book/src/developing/developing_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ Each component can define inputs and outputs, following these rules:

### Docker components good practices for [testcontainers-go](https://golang.testcontainers.org/):

An example [simple component](../../../../framework/components/blockchain/anvil.go)
An example [simple component](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/components/blockchain/anvil.go)

An example of [complex component](../../../../framework/components/clnode/clnode.go)
An example of [complex component](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/components/clnode/clnode.go)

An example of [composite component](../../../../framework/components/simple_node_set/node_set.go)
An example of [composite component](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/components/simple_node_set/node_set.go)

- Inputs should include at least `image`, `tag` and `pull_image` field
```golang
Expand Down
6 changes: 3 additions & 3 deletions book/src/framework/components/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

We use component caching to accelerate test development and enforce idempotent test actions.

Each component is designed to be pure with defined inputs/outputs.
Each component is isolated by means of inputs and outputs.

You can use an environment variable to skip deployment steps and use cached outputs if your infrastructure is already running (locally or remotely):
If cached config has any outputs with `use_cache = true` it will be used instead of deploying a component again.

```
export CTF_CONFIGS=smoke-cache.toml
Expand All @@ -26,4 +26,4 @@ http_url = 'http://127.0.0.1:33447'
docker_internal_ws_url = 'ws://anvil-3716a:8900'
docker_internal_http_url = 'http://anvil-3716a:8900'
```
Set flag `use_cache = true` on any component output and run your test again
Set flag `use_cache = true` on any component output, change output fields as needed and run your test again.
3 changes: 2 additions & 1 deletion book/src/framework/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

To start writing tests create a directory for your project with `go.mod` and pull the framework
```
go get github.com/smartcontractkit/chainlink-testing-framework/framework@ac819d889f97e0f5c04aee3212454ad1f8b6f4ef
go get github.com/smartcontractkit/chainlink-testing-framework/framework
```

Then download the CLI (runs from directory where you have `go.mod`)
Make sure you have your GOPATH set: `export GOPATH=$HOME/go && export PATH=$PATH:$GOPATH/bin`
```
go get github.com/smartcontractkit/chainlink-testing-framework/framework/cmd && \
go install github.com/smartcontractkit/chainlink-testing-framework/framework/cmd && \
Expand Down
2 changes: 0 additions & 2 deletions book/src/framework/nodeset_capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Create a configuration file `smoke.toml`
port = "8545"
type = "anvil"

[contracts]

[data_provider]
port = 9111

Expand Down
4 changes: 0 additions & 4 deletions book/src/framework/nodeset_compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ package capabilities_test
import (
"fmt"
"github.com/smartcontractkit/chainlink-testing-framework/framework"
"github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"
"github.com/smartcontractkit/chainlink-testing-framework/seth"
burn_mint_erc677 "github.com/smartcontractkit/chainlink/e2e/capabilities/components/gethwrappers"
"github.com/smartcontractkit/chainlink/e2e/capabilities/components/onchain"
"github.com/stretchr/testify/require"
"os"
"testing"
Expand Down
1 change: 0 additions & 1 deletion book/src/framework/nodeset_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"
"github.com/smartcontractkit/chainlink/e2e/capabilities/components/onchain"
"github.com/stretchr/testify/require"
"testing"
)
Expand Down
26 changes: 23 additions & 3 deletions book/src/framework/test_configuration_overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,28 @@ To override any test configuration, we merge multiple files into a single struct

You can specify multiple file paths using `CTF_CONFIGS=path1,path2,path3`.

The framework will apply these configurations from right to left.
The framework will apply these configurations from right to left and marshal them to a single test config structure.

> [!NOTE]
> When override slices remember that you should replace the full slice, it won't be extended by default!
Use it to structure the variations of your test, ex.:
```
export CTF_CONFIGS=smoke-test-feature-a-simulated-network.toml
export CTF_CONFIGS=smoke-test-feature-a-simulated-network.toml,smoke-test-feature-a-testnet.toml
export CTF_CONFIGS=smoke-test-feature-a.toml
export CTF_CONFIGS=smoke-test-feature-a.toml,smoke-test-feature-b.toml
export CTF_CONFIGS=load-profile-api-service-1.toml
export CTF_CONFIGS=load-profile-api-service-1.toml,load-profile-api-service-2.toml
```

This helps reduce duplication in the configuration.

> [!NOTE]
> We designed overrides to be as simple as possible, as frameworks like [envconfig](https://github.com/kelseyhightower/envconfig) and [viper](https://github.com/spf13/viper) offer extensive flexibility but can lead to inconsistent configurations prone to drift.
>
> This feature is meant to override test setup configurations, not test logic. Avoid using TOML to alter test logic.
>
> Tests should remain straightforward, readable, and perform a single set of actions (potentially across different CI/CD environments). If variations in test logic are required, consider splitting them into separate tests.
> [!WARNING]
> When override slices remember that you should replace the full slice, it won't be extended by default!
140 changes: 140 additions & 0 deletions book/src/k8s-test-runner/k8s-test-runner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
## Preparing to Run Tests on Staging

Ensure you complete the following steps before executing tests on the staging environment:

1. **Connect to the VPN**

2. **AWS Login with Staging Profile**

Authenticate to AWS using your staging profile, specifically with the `StagingEKSAdmin` role. Execute the following command:

```sh
aws sso login --profile staging
```

3. **Verify Authorization**

Confirm your authorization status by listing the namespaces in the staging cluster. Run `kubectl get namespaces`. If you see a list of namespaces, this indicates successful access to the staging cluster.

## Running Tests

### Creating an Image with the Test Binary

Before running tests, you must create a Docker image containing the test binary. To do this, execute the `create-test-image` command and provide the path to the test folder you wish to package. This command:

1. Compiles test binary under `<path-to-test-folder>`
2. Creates a docker image with the test binary
3. Pushes the docker image to the image registry (e.g. Staging ECR)

```sh
go run ./cmd/main.go create-test-image --image-registry-url <staging-ecr-registry-url> --image-tag "<image-tag>" "<path-to-test-folder>"
```

Where `image-tag` should be a descriptive name for your test, such as "mercury-load-tests".

### Running the Test in Kubernetes

If a Docker image containing the test binary is available in an image registry (such as staging ECR), use `run` command to execute the test in K8s.

```
go run ./cmd/main.go run -c "<path-to-test-runner-toml-config>"
```

The TOML config should specify the test runner configuration as follows:

```
namespace = "e2e-tests"
rbac_role_name = "" # RBAC role name for the chart
image_registry_url = "" # URL to the ECR containing the test binary image, e.g., staging ECR URL
image_name = "k8s-test-runner"
image_tag = "" # The image tag to use, like "mercury-load-tests" (see readme above)
job_count = "1"
test_name = "TestMercuryLoad/all_endpoints"
test_timeout = "24h"
test_config_base64_env_name = "LOAD_TEST_BASE64_TOML_CONTENT"
test_config_file_path = "/Users/lukasz/Documents/test-configs/load-staging-testnet.toml"
resources_requests_cpu = "1000m"
resources_requests_memory = "512Mi"
resources_limits_cpu = "2000m"
resources_limits_memory = "1024Mi"
[envs]
WASP_LOG_LEVEL = "info"
TEST_LOG_LEVEL = "info"
MERCURY_TEST_LOG_LEVEL = "info"
```

Where:

- `test_name` is the name of the test to run (must be included in the test binary).
- `test_config_env_name` is the name of the environment variable used to provide the test configuration for the test (optional).
- `test_config_file_path` is the path to the configuration file for the test (optional).

## Using K8s Test Runner on CI

### Example

This example demonstrates the process step by step. First, it shows how to download the Kubernetes Test Runner. Next, it details the use of the Test Runner to create a test binary specifically for the Mercury "e2e_tests/staging_prod/tests/load" test package. Finally, it describes executing the test in Kubernetes using a customized test runner configuration.

```
- name: Download K8s Test Runner
run: |
mkdir -p k8s-test-runner
cd k8s-test-runner
curl -L -o k8s-test-runner.tar.gz https://github.com/smartcontractkit/chainlink-testing-framework/releases/download/v0.2.4/test-runner.tar.gz
tar -xzf k8s-test-runner.tar.gz
chmod +x k8s-test-runner-linux-amd64
```

Alternatively, you can place the k8s-test-runner package within your repository and unpack it:

```
- name: Unpack K8s Test Runner
run: |
cd e2e_tests
mkdir -p k8s-test-runner
tar -xzf k8s-test-runner-v0.0.1.tar.gz -C k8s-test-runner
chmod +x k8s-test-runner/k8s-test-runner-linux-amd64
```

Then:

```
- name: Build K8s Test Runner Image
if: github.event.inputs.test-type == 'load' && github.event.inputs.rebuild-test-image == 'yes'
run: |
cd e2e_tests/k8s-test-runner
./k8s-test-runner-linux-amd64 create-test-image --image-registry-url "${{ secrets.AWS_ACCOUNT_ID_STAGING }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com" --image-tag "mercury-load-test" "../staging_prod/tests/load"
- name: Run Test in K8s
run: |
cd e2e_tests/k8s-test-runner
cat << EOF > config.toml
namespace = "e2e-tests"
rbac_role_name = "" # RBAC role name for the chart
image_registry_url = "${{ secrets.AWS_ACCOUNT_ID_STAGING }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com"
image_name = "k8s-test-runner"
image_tag = "mercury-load-test"
job_count = "1"
chart_path = "./chart"
test_name = "TestMercuryLoad/all_endpoints"
test_timeout = "24h"
resources_requests_cpu = "1000m"
resources_requests_memory = "512Mi"
resources_limits_cpu = "2000m"
resources_limits_memory = "1024Mi"
test_config_base64_env_name = "LOAD_TEST_BASE64_TOML_CONTENT"
test_config_base64 = "${{ steps.conditional-env-vars.outputs.LOAD_TEST_BASE64_TOML_CONTENT }}"
[envs]
WASP_LOG_LEVEL = "info"
TEST_LOG_LEVEL = "info"
MERCURY_TEST_LOG_LEVEL = "info"
EOF
./k8s-test-runner-linux-amd64 run -c config.toml
```

## Release

Run `./package <version>`
Loading

0 comments on commit d4379fc

Please sign in to comment.