From 2f162b44143ce6aebb8f17a57bc3a66ad2ad4829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20=C5=BDivkovi=C4=87?= Date: Mon, 25 Nov 2024 03:58:54 +0100 Subject: [PATCH] chore: remove ancient docker integration in `misc` (#3172) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR removes the ancient docker integration test contained in `misc` that fails, and a random docker compose, also in `misc`. This test package is actually never even run on `master`, because it requires a specific build flag `docker` 🤷‍♂️ Closes #3161
Contributors' checklist... - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests
--- .github/workflows/misc.yml | 20 +- go.mod | 2 +- misc/docker-compose/docker-compose.yml | 25 --- misc/docker-integration/Makefile | 2 - misc/docker-integration/README.md | 5 - misc/docker-integration/integration.go | 1 - misc/docker-integration/integration_test.go | 191 -------------------- 7 files changed, 10 insertions(+), 236 deletions(-) delete mode 100644 misc/docker-compose/docker-compose.yml delete mode 100644 misc/docker-integration/Makefile delete mode 100644 misc/docker-integration/README.md delete mode 100644 misc/docker-integration/integration.go delete mode 100644 misc/docker-integration/integration_test.go diff --git a/.github/workflows/misc.yml b/.github/workflows/misc.yml index 859e1429983..ad2c886e2ac 100644 --- a/.github/workflows/misc.yml +++ b/.github/workflows/misc.yml @@ -12,17 +12,15 @@ on: jobs: main: strategy: - fail-fast: false - matrix: - # fixed list because we have some non go programs on that misc folder - program: - - autocounterd - # - devdeps - - docker-integration - - genproto - - genstd - - goscan - - loop + fail-fast: false + matrix: + # fixed list because we have some non go programs on that misc folder + program: + - autocounterd + - genproto + - genstd + - goscan + - loop name: Run Main uses: ./.github/workflows/main_template.yml with: diff --git a/go.mod b/go.mod index 24d09a87236..f73ba1926e6 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,6 @@ require ( golang.org/x/term v0.23.0 golang.org/x/tools v0.24.0 google.golang.org/protobuf v1.35.1 - gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -69,4 +68,5 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect google.golang.org/grpc v1.65.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/misc/docker-compose/docker-compose.yml b/misc/docker-compose/docker-compose.yml deleted file mode 100644 index 470aeaf3127..00000000000 --- a/misc/docker-compose/docker-compose.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: "3.7" -services: - gnonode: - container_name: gnoland-node - build: - context: . - dockerfile: ../..Dockerfile - environment: - - LOG_LEVEL=4 - command: [ "gnoland", "start" ] - volumes: - - "gnonode:/opt/gno/src/gnoland-data" - networks: - - gnonode - restart: on-failure - logging: - driver: "json-file" - options: - max-file: "10" - max-size: "100m" - -networks: - gnonode: {} -volumes: - gnonode: {} diff --git a/misc/docker-integration/Makefile b/misc/docker-integration/Makefile deleted file mode 100644 index cd620d9be9f..00000000000 --- a/misc/docker-integration/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -test: - go test --tags=docker -v . diff --git a/misc/docker-integration/README.md b/misc/docker-integration/README.md deleted file mode 100644 index 21138ed033b..00000000000 --- a/misc/docker-integration/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# docker-integration - -This folder contains tests that runs integration tests inside Docker, using the CLIs. - -We encourage to keep the tests simple and focusing on cross-component testing. diff --git a/misc/docker-integration/integration.go b/misc/docker-integration/integration.go deleted file mode 100644 index 76ab1b7282d..00000000000 --- a/misc/docker-integration/integration.go +++ /dev/null @@ -1 +0,0 @@ -package integration diff --git a/misc/docker-integration/integration_test.go b/misc/docker-integration/integration_test.go deleted file mode 100644 index 973cb386e9b..00000000000 --- a/misc/docker-integration/integration_test.go +++ /dev/null @@ -1,191 +0,0 @@ -//go:build docker - -package integration - -import ( - "encoding/json" - "fmt" - "os" - "os/exec" - "path/filepath" - "strings" - "testing" - "time" - - "github.com/gnolang/gno/gno.land/pkg/gnoland" - "github.com/gnolang/gno/gno.land/pkg/gnoland/ugnot" - "github.com/gnolang/gno/gno.land/pkg/sdk/vm" - "github.com/gnolang/gno/tm2/pkg/amino" - "github.com/gnolang/gno/tm2/pkg/std" - "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" -) - -const ( - gnolandContainerName = "int_gnoland" - - test1Addr = "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" - test1Seed = "source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast" - dockerWaitTimeout = 30 -) - -func TestDockerIntegration(t *testing.T) { - t.Parallel() - - tmpdir, err := os.MkdirTemp(os.TempDir(), "*-gnoland-integration") - require.NoError(t, err) - - checkDocker(t) - cleanupGnoland(t) - buildDockerImage(t) - startGnoland(t) - waitGnoland(t) - - runSuite(t, tmpdir) -} - -func runSuite(t *testing.T, tempdir string) { - t.Helper() - - // add test1 account to docker container keys with "pass" password - dockerExec(t, fmt.Sprintf( - `echo "pass\npass\n%s\n" | gnokey add -recover -insecure-password-stdin test1`, - test1Seed, - )) - // assert test1 account exists - var acc gnoland.GnoAccount - dockerExec_gnokeyQuery(t, "auth/accounts/"+test1Addr, &acc) - require.Equal(t, test1Addr, acc.Address.String(), "test1 account not found") - - // This value is chosen arbitrarily and may not be optimal. - // Feel free to update it to a more suitable amount. - minCoins := std.MustParseCoins(ugnot.ValueString(9990000000000)) - require.True(t, acc.Coins.IsAllGTE(minCoins), - "test1 account coins expected at least %s, got %s", minCoins, acc.Coins) - - // add gno.land/r/demo/tests package as tests_copy - dockerExec(t, - `echo 'pass' | gnokey maketx addpkg -insecure-password-stdin \ - -gas-fee 1000000ugnot -gas-wanted 2000000 \ - -broadcast -chainid dev \ - -pkgdir /opt/gno/src/examples/gno.land/r/demo/tests/ \ - -pkgpath gno.land/r/demo/tests_copy \ - -deposit 100000000ugnot \ - test1`, - ) - // assert gno.land/r/demo/tests_copy has been added - var qfuncs vm.FunctionSignatures - dockerExec_gnokeyQuery(t, `-data "gno.land/r/demo/tests_copy" vm/qfuncs`, &qfuncs) - require.True(t, len(qfuncs) > 0, "gno.land/r/demo/tests_copy not added") - - // broadcast a package TX - dockerExec(t, - `echo 'pass' | gnokey maketx call -insecure-password-stdin \ - -gas-fee 1000000ugnot -gas-wanted 2000000 \ - -broadcast -chainid dev \ - -pkgpath "gno.land/r/demo/tests_copy" -func "InitTestNodes" \ - test1`, - ) -} - -func checkDocker(t *testing.T) { - t.Helper() - output, err := createCommand(t, []string{"docker", "info"}).CombinedOutput() - require.NoError(t, err, "docker daemon not running: %s", string(output)) -} - -func buildDockerImage(t *testing.T) { - t.Helper() - - cmd := createCommand(t, []string{ - "docker", - "build", - "-t", "gno:integration", - filepath.Join("..", ".."), - }) - output, err := cmd.CombinedOutput() - require.NoError(t, err, string(output)) -} - -// dockerExec runs docker exec with cmd as argument -func dockerExec(t *testing.T, cmd string) []byte { - t.Helper() - - cmds := append( - []string{"docker", "exec", gnolandContainerName, "sh", "-c"}, - cmd, - ) - bz, err := createCommand(t, cmds).CombinedOutput() - require.NoError(t, err, string(bz)) - return bz -} - -// dockerExec_gnokeyQuery runs dockerExec with gnokey query prefix and parses -// the command output to out. -func dockerExec_gnokeyQuery(t *testing.T, cmd string, out any) { - t.Helper() - - output := dockerExec(t, "gnokey query "+cmd) - // parses the output of gnokey query: - // height: h - // data: { JSON } - var resp struct { - Height int64 `yaml:"height"` - Data any `yaml:"data"` - } - err := yaml.Unmarshal(output, &resp) - require.NoError(t, err) - bz, err := json.Marshal(resp.Data) - require.NoError(t, err) - err = amino.UnmarshalJSON(bz, out) - require.NoError(t, err) -} - -func createCommand(t *testing.T, args []string) *exec.Cmd { - t.Helper() - msg := strings.Join(args, " ") - t.Log(msg) - return exec.Command(args[0], args[1:]...) -} - -func startGnoland(t *testing.T) { - t.Helper() - - cmd := createCommand(t, []string{ - "docker", "run", - "-d", - "--name", gnolandContainerName, - "-w", "/opt/gno/src/gno.land", - "gno:integration", - "gnoland", - "start", - }) - output, err := cmd.CombinedOutput() - require.NoError(t, err) - require.NotEmpty(t, string(output)) // should be the hash of the container. - - // t.Cleanup(func() { cleanupGnoland(t) }) -} - -func waitGnoland(t *testing.T) { - t.Helper() - t.Log("waiting...") - for i := 0; i < dockerWaitTimeout; i++ { - output, _ := createCommand(t, - []string{"docker", "logs", gnolandContainerName}, - ).CombinedOutput() - if strings.Contains(string(output), "Committed state") { - // ok blockchain is ready - t.Log("gnoland ready") - return - } - time.Sleep(time.Second) - } - // cleanupGnoland(t) - panic("gnoland start timeout") -} - -func cleanupGnoland(t *testing.T) { - t.Helper() - createCommand(t, []string{"docker", "rm", "-f", gnolandContainerName}).Run() -}