From 43fe6d467d54eb532d470ea3b7d95d750c82053e Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Tue, 9 May 2023 15:41:21 -0700 Subject: [PATCH 01/13] update integration test readme --- integration_test/README.md | 46 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/integration_test/README.md b/integration_test/README.md index 1c7e3928..5362a3bf 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -1,25 +1,41 @@ # Integration test -The test ensures that Signatory can perform an authenticated sign operations -while assisting `octez-client`. +The tests in this folder use a docker compose file to orchestrate the starting of `Signatory`, `flextesa` and `tezos` containers. -From the project tree root +The version of Signatory that is run is defined by an environment variable named `IMAGE`. +The `octez-client` that is run by the tests is provided by the `tezos` container, not the `octez-client` that is onboard the `flextesa` image, so that official `tezos` image releases can be used. The version of `tezos` container is defined by an environment variable named `OCTEZ_VERSION`. + +Currently, it is always the `latest` version of the `flextesa` image that is run by the tests, which protocol the testnet runs is defined in the script `flextesa.sh` + +# Running the tests + +Pull the images for the version and architecture that suit your needs. Example: ```sh -docker build --no-cache -t signatory-test -f ./integration_test/Dockerfile . -docker run --rm -e 'ENV_NODE_ADDR={...}' -e 'ENV_SECRET_KEY={...}' signatory-test +export SIGY_IMAGE=ghcr.io/ecadlabs/signatory:v1.0.0-beta3-arm64 +export OCTEZ_VERSION=arm64_v16.0-rc3 +docker pull oxheadalpha/flextesa:latest +docker pull tezos/tezos:$OCTEZ_VERSION +docker pull $SIGY_IMAGE ``` -where `ENV_NODE_ADDR` is the name of a testnet node example: https://ghostnet.ecadinfra.com -and `ENV_SECRET_KEY` is an unencrypted private key of an implicit, funded account on the testnet -the private key of alice can be used: edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq +Next, start the stack: +```sh +cd integration_test +IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION docker compose up -d --wait +``` -## Environment variables +Run all the tests: +```sh +IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION go test ./... +``` -| Name | Default value | Description | -| ------------------ | ------------------------------- | ------------------------------------------------------------------- | -| ENV_SECRET_KEY | | Private key in Tezos Base58 format. | -| ENV_NODE_ADDR | https://ghostnet.ecadinfra.com | Testnet node | +Or, just run a single test: +```sh +IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION go test -run ^TestJWTHappyPath +``` -## Add new testnet endpoint in Github CI -To add a new testnet to the `testnet_endpoints` list in `.github/workflows/integration-tests.yaml` we also need to make sure to fund the wallet `tz3NxnbanoQ9hyn3wcxZ3q9XGCaNSvmARv3Z` with some XTZ on the new testnet +Stop the stack when you are done: +```sh +IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION docker compose down +``` From afced246d73f20d08af6eed0cedbd93e84c9a196 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Fri, 12 May 2023 13:18:31 -0700 Subject: [PATCH 02/13] readme feedback incorporated --- integration_test/README.md | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/integration_test/README.md b/integration_test/README.md index 5362a3bf..26826d8c 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -1,19 +1,33 @@ -# Integration test +## Integration test -The tests in this folder use a docker compose file to orchestrate the starting of `Signatory`, `flextesa` and `tezos` containers. +The tests in this folder use a docker compose file to orchestrate the starting of `Signatory`, `flextesa` and `tezos` containers. -The version of Signatory that is run is defined by an environment variable named `IMAGE`. +The version of Signatory that is run is defined by an environment variable named `IMAGE`. -The `octez-client` that is run by the tests is provided by the `tezos` container, not the `octez-client` that is onboard the `flextesa` image, so that official `tezos` image releases can be used. The version of `tezos` container is defined by an environment variable named `OCTEZ_VERSION`. +The `octez-client` that is run by the tests is provided by the `tezos` container, not the `octez-client` that is onboard the `flextesa` image, so that official `tezos` image releases can be used. The version of `tezos` container is defined by an environment variable named `OCTEZ_VERSION`. Currently, it is always the `latest` version of the `flextesa` image that is run by the tests, which protocol the testnet runs is defined in the script `flextesa.sh` -# Running the tests +## Pulling the images -Pull the images for the version and architecture that suit your needs. Example: +Pre-release Signatory images are available in [github container registry](https://github.com/ecadlabs/signatory/pkgs/container/signatory) +Official image releases are available in [dockerhub](https://hub.docker.com/r/ecadlabs/signatory/tags) + +### Github container registry authentication setup + +If this is your first time pulling an image from github packages, then you'll need to configure a [Personal Access Token PAT (classic)](https://github.com/settings/tokens). The only access you should grant the PAT is `read:packages`. With that token as the value of env var $PAT, you can now login: ```sh -export SIGY_IMAGE=ghcr.io/ecadlabs/signatory:v1.0.0-beta3-arm64 -export OCTEZ_VERSION=arm64_v16.0-rc3 +echo $PAT |docker login ghcr.io -u --password-stdin +``` + +## Running the tests + +Pull the images for the version and architecture that suit your needs from [flextesa](https://hub.docker.com/r/oxheadalpha/flextesa/tags), [tezos](https://hub.docker.com/r/tezos/tezos/tags), [signatory (pre-release)](https://github.com/ecadlabs/signatory/pkgs/container/signatory/versions), or [signatory (release)](https://hub.docker.com/r/ecadlabs/signatory/tags) + +Example: +```sh +export SIGY_IMAGE=ghcr.io/ecadlabs/signatory:main-arm64 +export OCTEZ_VERSION=arm64_v17.0-beta1 docker pull oxheadalpha/flextesa:latest docker pull tezos/tezos:$OCTEZ_VERSION docker pull $SIGY_IMAGE @@ -39,3 +53,7 @@ Stop the stack when you are done: ```sh IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION docker compose down ``` + +## Notes to the operator + +Some tests in this folder make edits to `signatory.yaml` configuration and restart the Signatory service. By design, tests that do this shall clean up after themselves by restoring the copy of the file that is in the code repository. If `git status` after a test run shows you have modifications to the `signatory.yaml` file, then that would mean a test is failing to clean up after itself and should be corrected. \ No newline at end of file From 0882f6294cf0c380cad58e4d676f24d6ab7fc75b Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Fri, 12 May 2023 14:52:30 -0700 Subject: [PATCH 03/13] remove Log.Fatal and improve logging on fail --- integration_test/README.md | 12 +++++++++--- integration_test/config.go | 5 ++--- integration_test/flextesa.sh | 2 +- integration_test/octezclient.go | 5 ++--- integration_test/operationkinds_test.go | 2 +- integration_test/service.go | 15 +++++++-------- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/integration_test/README.md b/integration_test/README.md index 26826d8c..5c41e65a 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -15,7 +15,8 @@ Official image releases are available in [dockerhub](https://hub.docker.com/r/ec ### Github container registry authentication setup -If this is your first time pulling an image from github packages, then you'll need to configure a [Personal Access Token PAT (classic)](https://github.com/settings/tokens). The only access you should grant the PAT is `read:packages`. With that token as the value of env var $PAT, you can now login: +If this is your first time pulling an image from github packages, then you'll need to configure a [Personal Access Token PAT (classic)](https://github.com/settings/tokens). The only access you should grant the PAT is `read:packages`. With that token as the value of env var `$PAT`, you can now login: + ```sh echo $PAT |docker login ghcr.io -u --password-stdin ``` @@ -25,6 +26,7 @@ echo $PAT |docker login ghcr.io -u --password-stdin Pull the images for the version and architecture that suit your needs from [flextesa](https://hub.docker.com/r/oxheadalpha/flextesa/tags), [tezos](https://hub.docker.com/r/tezos/tezos/tags), [signatory (pre-release)](https://github.com/ecadlabs/signatory/pkgs/container/signatory/versions), or [signatory (release)](https://hub.docker.com/r/ecadlabs/signatory/tags) Example: + ```sh export SIGY_IMAGE=ghcr.io/ecadlabs/signatory:main-arm64 export OCTEZ_VERSION=arm64_v17.0-beta1 @@ -34,26 +36,30 @@ docker pull $SIGY_IMAGE ``` Next, start the stack: + ```sh cd integration_test IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION docker compose up -d --wait ``` Run all the tests: + ```sh IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION go test ./... ``` Or, just run a single test: + ```sh -IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION go test -run ^TestJWTHappyPath +IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION go test -run ^TestOperationAllowPolicy ``` Stop the stack when you are done: + ```sh IMAGE=$SIGY_IMAGE OCTEZ_VERSION=$OCTEZ_VERSION docker compose down ``` ## Notes to the operator -Some tests in this folder make edits to `signatory.yaml` configuration and restart the Signatory service. By design, tests that do this shall clean up after themselves by restoring the copy of the file that is in the code repository. If `git status` after a test run shows you have modifications to the `signatory.yaml` file, then that would mean a test is failing to clean up after itself and should be corrected. \ No newline at end of file +Some tests in this folder make edits to `signatory.yaml` configuration and restart the Signatory service. By design, tests that do this shall clean up after themselves by restoring the copy of the file that is in the code repository. If `git status` after a test run shows you have modifications to the `signatory.yaml` file, then that would mean a test is failing to clean up after itself and should be corrected. diff --git a/integration_test/config.go b/integration_test/config.go index 60b2a9b3..de270127 100644 --- a/integration_test/config.go +++ b/integration_test/config.go @@ -1,7 +1,6 @@ package integrationtest import ( - "log" "os" yaml "gopkg.in/yaml.v3" @@ -50,10 +49,10 @@ func (c *Config) Read(file string) error { func (c *Config) Write(file string) error { yamlFile, err := yaml.Marshal(c) if err != nil { - log.Fatal(err) + panic(err) } if err = os.WriteFile(file, yamlFile, 0644); err != nil { - log.Fatal(err) + panic(err) } return nil diff --git a/integration_test/flextesa.sh b/integration_test/flextesa.sh index 653ebdcd..b39fcdd2 100755 --- a/integration_test/flextesa.sh +++ b/integration_test/flextesa.sh @@ -1,6 +1,6 @@ #! /bin/sh -protocol=Mumbai +protocol=Nairobi time_bb=${block_time:-1} diff --git a/integration_test/octezclient.go b/integration_test/octezclient.go index 0cdf1442..122cd64c 100644 --- a/integration_test/octezclient.go +++ b/integration_test/octezclient.go @@ -1,7 +1,6 @@ package integrationtest import ( - "log" "os/exec" ) @@ -17,7 +16,7 @@ func delete_wallet_lock() { var args = []string{"exec", "octez", "rm", "-f", "/home/tezos/.tezos-client/wallet_lock"} out, err := exec.Command(cmd, args...).CombinedOutput() if err != nil { - log.Fatal("Failed to delete wallet lock: " + string(out)) + panic("Failed to delete wallet lock: " + string(out)) } } @@ -26,6 +25,6 @@ func delete_contracts_aliases() { var args = []string{"exec", "octez", "rm", "-f", "/home/tezos/.tezos-client/contracts"} out, err := exec.Command(cmd, args...).CombinedOutput() if err != nil { - log.Fatal("Failed to delete contracts: " + string(out)) + panic("Failed to delete contracts: " + string(out)) } } diff --git a/integration_test/operationkinds_test.go b/integration_test/operationkinds_test.go index 04a0fe6d..634341a1 100644 --- a/integration_test/operationkinds_test.go +++ b/integration_test/operationkinds_test.go @@ -103,7 +103,7 @@ func TestOperationAllowPolicy(t *testing.T) { //first, do any setup steps that have to happen before the operation to be tested for _, setupOp := range test.testSetupOps { out, err := OctezClient(setupOp...) - require.NoError(t, err) + assert.NoError(t, err) require.Contains(t, string(out), "Operation successfully injected in the node") } diff --git a/integration_test/service.go b/integration_test/service.go index 827a5eee..86f442d8 100644 --- a/integration_test/service.go +++ b/integration_test/service.go @@ -1,36 +1,35 @@ package integrationtest import ( - "log" "os/exec" ) func restart_signatory() { _, err := exec.Command("docker", "compose", "-f", "./docker-compose.yml", "stop", "signatory").CombinedOutput() if err != nil { - log.Fatal("failed to stop signatory") + panic("failed to stop signatory") } _, err = exec.Command("docker", "compose", "-f", "./docker-compose.yml", "up", "-d", "--wait", "signatory").CombinedOutput() if err != nil { - log.Fatal("failed to start signatory during restart") + panic("failed to start signatory during restart") } } func backup_then_update_config(c Config) { _, err := exec.Command("cp", "signatory.yaml", "signatory.original.yaml").CombinedOutput() if err != nil { - log.Fatal("failed to backup config") + panic("failed to backup config") } err = c.Write("signatory.yaml") if err != nil { - log.Fatal("failed to write new config") + panic("failed to write new config") } } func restore_config() { _, err := exec.Command("mv", "signatory.original.yaml", "signatory.yaml").CombinedOutput() if err != nil { - log.Fatal("failed to restore original config") + panic("failed to restore original config") } restart_signatory() } @@ -38,10 +37,10 @@ func restore_config() { func restart_stack() { _, err := exec.Command("docker", "compose", "-f", "./docker-compose.yml", "kill").CombinedOutput() if err != nil { - log.Fatal("failed to kill stack") + panic("failed to kill stack") } _, err = exec.Command("docker", "compose", "-f", "./docker-compose.yml", "up", "-d", "--wait").CombinedOutput() if err != nil { - log.Fatal("failed to up stack") + panic("failed to up stack") } } From 65f285ecde4126c0e0681746f3d41bb693dc6760 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Fri, 12 May 2023 14:54:10 -0700 Subject: [PATCH 04/13] revert to Mumbai. change to Nairobi was a mistake - tests with chainID in them break there --- integration_test/flextesa.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test/flextesa.sh b/integration_test/flextesa.sh index b39fcdd2..653ebdcd 100755 --- a/integration_test/flextesa.sh +++ b/integration_test/flextesa.sh @@ -1,6 +1,6 @@ #! /bin/sh -protocol=Nairobi +protocol=Mumbai time_bb=${block_time:-1} From c1851360a3e99aad78144f48906b3aa4b579b33c Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Mon, 15 May 2023 15:46:46 -0700 Subject: [PATCH 05/13] sg-integration-test adding chain protocol via env var --- .github/workflows/build.yaml | 15 ++++++++------- integration_test/docker-compose.yml | 2 +- integration_test/env.current.amd64 | 4 ++++ integration_test/env.current.arm64 | 4 ++++ integration_test/env.next.amd64 | 4 ++++ integration_test/env.next.arm64 | 4 ++++ integration_test/flextesa.sh | 4 ++-- integration_test/service.go | 7 ++++--- 8 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 integration_test/env.current.amd64 create mode 100644 integration_test/env.current.arm64 create mode 100644 integration_test/env.next.amd64 create mode 100644 integration_test/env.next.arm64 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fb59c4dc..a2333bcc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -107,10 +107,9 @@ jobs: strategy: fail-fast: false matrix: - octez-versions: - - v16.0-rc3 - env: - IMAGE: ghcr.io/ecadlabs/signatory:${{ github.head_ref || github.ref_name }}-amd64 + testenvs: + - env.current.amd64 + - env.next.amd64 steps: - uses: actions/checkout@v2 - name: Login to DockerHub @@ -120,16 +119,18 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set env + run: export $(xargs <${{ matrix.testenvs }}); export IMAGE=ghcr.io/ecadlabs/signatory:${{ github.head_ref || github.ref_name }}-amd64 - name: Pull images run: > docker pull oxheadalpha/flextesa:latest; docker pull tezos/tezos:${{ matrix.octez-versions }}; docker pull $IMAGE; - name: Start containers - run: IMAGE=$IMAGE OCTEZ_VERSION=${{ matrix.octez-versions }} docker compose -f integration_test/docker-compose.yml up -d --wait + run: docker compose --env-file ${{ matrix.testenvs }} -f integration_test/docker-compose.yml up -d --wait - name: Modify octez run: docker exec octez sudo chown -R tezos /home/tezos/.tezos-client - name: Run tests - run: IMAGE=$IMAGE OCTEZ_VERSION=${{ matrix.octez-versions }} go test $(go list ./... | grep integration_test) + run: go test $(go list ./... | grep integration_test) - name: Kill containers - run: IMAGE=$IMAGE OCTEZ_VERSION=${{ matrix.octez-versions }} docker compose -f integration_test/docker-compose.yml kill + run: docker compose -f integration_test/docker-compose.yml kill diff --git a/integration_test/docker-compose.yml b/integration_test/docker-compose.yml index 3cbcbeae..e96f62ae 100644 --- a/integration_test/docker-compose.yml +++ b/integration_test/docker-compose.yml @@ -15,7 +15,7 @@ services: - ./flextesa.sh:/usr/bin/sigybox environment: - block_time=3 - command: sigybox + command: sigybox $PROTOCOL healthcheck: test: "curl --fail http://localhost:20000/chains/main/blocks/head/header || exit 1" interval: 1s diff --git a/integration_test/env.current.amd64 b/integration_test/env.current.amd64 new file mode 100644 index 00000000..b50824e2 --- /dev/null +++ b/integration_test/env.current.amd64 @@ -0,0 +1,4 @@ +IMAGE=ghcr.io/ecadlabs/signatory:main-amd64 +OCTEZ_VERSION=amd64_v16.0-rc3 +PROTOCOL=Mumbai +TESTENV=current.amd64 diff --git a/integration_test/env.current.arm64 b/integration_test/env.current.arm64 new file mode 100644 index 00000000..a7966288 --- /dev/null +++ b/integration_test/env.current.arm64 @@ -0,0 +1,4 @@ +IMAGE=ghcr.io/ecadlabs/signatory:main-arm64 +OCTEZ_VERSION=arm64_v16.0-rc3 +PROTOCOL=Mumbai +TESTENV=current.arm64 diff --git a/integration_test/env.next.amd64 b/integration_test/env.next.amd64 new file mode 100644 index 00000000..4522d906 --- /dev/null +++ b/integration_test/env.next.amd64 @@ -0,0 +1,4 @@ +IMAGE=ghcr.io/ecadlabs/signatory:main-amd64 +OCTEZ_VERSION=amd64_v17.0-beta1 +PROTOCOL=Nairobi +TESTENV=next.amd64 diff --git a/integration_test/env.next.arm64 b/integration_test/env.next.arm64 new file mode 100644 index 00000000..aba30c78 --- /dev/null +++ b/integration_test/env.next.arm64 @@ -0,0 +1,4 @@ +IMAGE=ghcr.io/ecadlabs/signatory:main-arm64 +OCTEZ_VERSION=arm64_v17.0-beta1 +PROTOCOL=Nairobi +TESTENV=next.arm64 diff --git a/integration_test/flextesa.sh b/integration_test/flextesa.sh index 653ebdcd..93d2ff87 100755 --- a/integration_test/flextesa.sh +++ b/integration_test/flextesa.sh @@ -1,6 +1,6 @@ #! /bin/sh -protocol=Mumbai +protocol=$1 time_bb=${block_time:-1} @@ -13,7 +13,7 @@ export user1="user1,edpkvNSVE2pL4eaCYrew1NEuLi4nnYmwQfe4tdM4NoVgNMEoVCNGoW,tz1Qg root_path=/tmp/mini-box flextesa mini-net \ - --root "$root_path" --size 1 "$@" \ + --root "$root_path" --size 1 \ --set-history-mode N000:archive \ --number-of-b 1 \ --balance-of-bootstrap-accounts tez:100_000_000 \ diff --git a/integration_test/service.go b/integration_test/service.go index 86f442d8..09b14d8b 100644 --- a/integration_test/service.go +++ b/integration_test/service.go @@ -1,15 +1,16 @@ package integrationtest import ( + "os" "os/exec" ) func restart_signatory() { - _, err := exec.Command("docker", "compose", "-f", "./docker-compose.yml", "stop", "signatory").CombinedOutput() + _, err := exec.Command("docker", "compose", "--env-file", "env."+os.Getenv("TESTENV"), "-f", "./docker-compose.yml", "stop", "signatory").CombinedOutput() if err != nil { panic("failed to stop signatory") } - _, err = exec.Command("docker", "compose", "-f", "./docker-compose.yml", "up", "-d", "--wait", "signatory").CombinedOutput() + _, err = exec.Command("docker", "compose", "--env-file", "env."+os.Getenv("TESTENV"), "-f", "./docker-compose.yml", "up", "-d", "--wait", "signatory").CombinedOutput() if err != nil { panic("failed to start signatory during restart") } @@ -35,7 +36,7 @@ func restore_config() { } func restart_stack() { - _, err := exec.Command("docker", "compose", "-f", "./docker-compose.yml", "kill").CombinedOutput() + _, err := exec.Command("docker", "compose", "--env-file", "env."+os.Getenv("TESTENV"), "-f", "./docker-compose.yml", "kill").CombinedOutput() if err != nil { panic("failed to kill stack") } From db7ffc79bdbc8f249f08bfd46a8bef04ecc1edb8 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Mon, 15 May 2023 15:57:35 -0700 Subject: [PATCH 06/13] sg-integrationtest fix workflow env var --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a2333bcc..5b3dbad7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -124,7 +124,7 @@ jobs: - name: Pull images run: > docker pull oxheadalpha/flextesa:latest; - docker pull tezos/tezos:${{ matrix.octez-versions }}; + docker pull tezos/tezos:$OCTEZ_VERSION; docker pull $IMAGE; - name: Start containers run: docker compose --env-file ${{ matrix.testenvs }} -f integration_test/docker-compose.yml up -d --wait From d099f2dd2f31054f7fb8174c833e2f34cce558de Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Mon, 15 May 2023 15:59:47 -0700 Subject: [PATCH 07/13] sg-integrationtest fix workflow path to env file --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5b3dbad7..3afd5801 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -120,7 +120,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set env - run: export $(xargs <${{ matrix.testenvs }}); export IMAGE=ghcr.io/ecadlabs/signatory:${{ github.head_ref || github.ref_name }}-amd64 + run: export $(xargs docker pull oxheadalpha/flextesa:latest; From 57da431ec7276437b407449b69901a97764dca0a Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Mon, 15 May 2023 16:06:27 -0700 Subject: [PATCH 08/13] sg-integrationtest more fixing of paths --- .github/workflows/build.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3afd5801..055574ea 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -119,18 +119,18 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set env - run: export $(xargs + export $(xargs Date: Mon, 15 May 2023 16:26:56 -0700 Subject: [PATCH 09/13] sg-integrationtest fix test step --- .github/workflows/build.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 055574ea..843f8bc4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -131,6 +131,9 @@ jobs: - name: Modify octez run: docker exec octez sudo chown -R tezos /home/tezos/.tezos-client - name: Run tests - run: go test $(go list ./... | grep integration_test) + run: > + export $(xargs Date: Mon, 15 May 2023 17:08:16 -0700 Subject: [PATCH 10/13] sg-integrationtest simplify workflow's env var --- .github/workflows/build.yaml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 843f8bc4..2f79cf9a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -119,21 +119,11 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Pull images - run: > - export $(xargs export $(xargs Date: Mon, 15 May 2023 17:50:49 -0700 Subject: [PATCH 11/13] sg-integrationtest remove use of --env-var option and update readme --- integration_test/README.md | 36 ++++++++++++++++++------------ integration_test/env.current.amd64 | 2 -- integration_test/env.current.arm64 | 2 -- integration_test/env.next.amd64 | 2 -- integration_test/env.next.arm64 | 2 -- integration_test/service.go | 9 ++++---- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/integration_test/README.md b/integration_test/README.md index 1e91543d..e47a2a3d 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -6,15 +6,19 @@ The version of Signatory that is run is defined by an environment variable named The `octez-client` that is run by the tests is provided by the `tezos` container, not the `octez-client` that is onboard the `flextesa` image, so that official `tezos` image releases can be used. The version of `tezos` container is defined by an environment variable named `OCTEZ_VERSION`. -Currently, it is always the `latest` version of the `flextesa` image that is run by the tests, which protocol the testnet runs is defined in the script `flextesa.sh` +Currently, it is always the `latest` version of the `flextesa` image that is run by the tests. The economic protocol run by flextesa is defined by an environment variable named `PROTOCOL` ## Pulling the images Pre-release Signatory images are available in [github container registry](https://github.com/ecadlabs/signatory/pkgs/container/signatory) Official image releases are available in [dockerhub](https://hub.docker.com/r/ecadlabs/signatory/tags) -If you get a 404 from the github container registry, you can request access from an admin. +If you get a 404 from the github container registry web console, you can request access from an admin. -### Github container registry authentication setup +[flextesa](https://hub.docker.com/r/oxheadalpha/flextesa/tags) image is used. + +[tezos](https://hub.docker.com/r/tezos/tezos/tags) image is used + +## Github container registry authentication setup If this is your first time pulling an image from github packages, then you'll need to configure a [Personal Access Token PAT (classic)](https://github.com/settings/tokens). The only access you should grant the PAT is `read:packages`. With that token as the value of env var `$PAT`, you can now login: @@ -24,41 +28,45 @@ echo $PAT |docker login ghcr.io -u --password-stdin ## Running the tests -Pull the images for the version and architecture that suit your needs from [flextesa](https://hub.docker.com/r/oxheadalpha/flextesa/tags), [tezos](https://hub.docker.com/r/tezos/tezos/tags), [signatory (pre-release)](https://github.com/ecadlabs/signatory/pkgs/container/signatory/versions), or [signatory (release)](https://hub.docker.com/r/ecadlabs/signatory/tags) +Exporting the Environment Variables used by the test is required. Choose the set of env var to use from the files `env.current.arm64`, `env.next.arm64`, `env.current.amd64`, `env.next.amd64`. Use `current` if you'd like the economic protocol run by flextesa to match mainnet, use `next` if you'd like the next protocol instead. Use `arm64` or `amd64` depending on your host architecture. + +So, to set the env to use mainnet protocol, using a build of Signatory's `main` branch, on a macbook m1 host: + +```sh +export $(xargs Date: Mon, 15 May 2023 18:08:56 -0700 Subject: [PATCH 12/13] sg-integrationtest small readme update --- integration_test/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integration_test/README.md b/integration_test/README.md index e47a2a3d..23757636 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -28,6 +28,10 @@ echo $PAT |docker login ghcr.io -u --password-stdin ## Running the tests +```sh +cd integration_test +``` + Exporting the Environment Variables used by the test is required. Choose the set of env var to use from the files `env.current.arm64`, `env.next.arm64`, `env.current.amd64`, `env.next.amd64`. Use `current` if you'd like the economic protocol run by flextesa to match mainnet, use `next` if you'd like the next protocol instead. Use `arm64` or `amd64` depending on your host architecture. So, to set the env to use mainnet protocol, using a build of Signatory's `main` branch, on a macbook m1 host: @@ -47,7 +51,6 @@ export IMAGE=ghcr.io/ecadlabs/signatory:main-amd64 Next, start the stack: ```sh -cd integration_test docker compose up -d --wait --pull always ``` From 576080dd7fbd38bfb1921c85d3707254e5d4a769 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Tue, 16 May 2023 08:25:37 -0700 Subject: [PATCH 13/13] sg-integrationtest update readme with re-running tests instruction --- integration_test/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration_test/README.md b/integration_test/README.md index 23757636..9fc0c684 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -72,6 +72,10 @@ Stop the stack when you are done: docker compose down ``` +## Re-Running Tests + +Most tests can be re-run successfully as detailed above. Some tests (like the `reveal` operation) can only be run once on a chain. So, when re-running all, stop the stack and bring it up again in between test runs. + ## Notes to the operator Some tests in this folder make edits to `signatory.yaml` configuration and restart the Signatory service. By design, tests that do this shall clean up after themselves by restoring the copy of the file that is in the code repository. If `git status` after a test run shows you have modifications to the `signatory.yaml` file, then that would mean a test is failing to clean up after itself and should be corrected.