gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
899 stars 377 forks source link

`TestDockerIntegration` fails when ran locally #3161

Closed zivkovicmilos closed 22 hours ago

zivkovicmilos commented 6 days ago

TestDockerIntegration fails locally

Description

Running the test TestDockerIntegration fails locally, even with the build tag docker.

Docker version on my machine:

Client:
 Cloud integration: v1.0.35+desktop.13
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:14:46 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.29.0 (145265)
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:02 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Your environment

Steps to reproduce

Head over to misc/docker-integration and run make test

Expected behavior

The test should pass.

Actual behavior

The test panics.

Logs

make test
go test --tags=docker -v .
=== RUN   TestDockerIntegration
=== PAUSE TestDockerIntegration
=== CONT  TestDockerIntegration
    integration_test.go:38: docker info
    integration_test.go:39: docker rm -f int_gnoland
    integration_test.go:40: docker build -t gno:integration ../..
    integration_test.go:41: docker run -d --name int_gnoland -w /opt/gno/src/gno.land gno:integration gnoland start
    integration_test.go:42: waiting...
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
--- FAIL: TestDockerIntegration (33.84s)
panic: gnoland start timeout [recovered]
        panic: gnoland start timeout

goroutine 5 [running]:
testing.tRunner.func1.2({0x102e7a940, 0x102fcdd40})
        /opt/homebrew/opt/go/libexec/src/testing/testing.go:1632 +0x1bc
testing.tRunner.func1()
        /opt/homebrew/opt/go/libexec/src/testing/testing.go:1635 +0x334
panic({0x102e7a940?, 0x102fcdd40?})
        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:785 +0x124
github.com/gnolang/gno/misc/docker-integration.waitGnoland(0x1400046e340)
        /Users/zmilos/Work/gno/misc/docker-integration/integration_test.go:185 +0x150
github.com/gnolang/gno/misc/docker-integration.TestDockerIntegration(0x1400046e340)
        /Users/zmilos/Work/gno/misc/docker-integration/integration_test.go:42 +0xa4
testing.tRunner(0x1400046e340, 0x102fcb090)
        /opt/homebrew/opt/go/libexec/src/testing/testing.go:1690 +0xe4
created by testing.(*T).Run in goroutine 1
        /opt/homebrew/opt/go/libexec/src/testing/testing.go:1743 +0x314
FAIL    github.com/gnolang/gno/misc/docker-integration  34.244s
FAIL
make: *** [test] Error 1

Proposed solution

🤷‍♂️

zivkovicmilos commented 6 days ago

This is the output of the image:

2024-11-20 01:25:48 unable to load config; try running `gnoland config init` or use the -lazy flag, config file at "/opt/gno/src/gno.land/gnoland-data/config/config.toml" does not exist
zivkovicmilos commented 6 days ago

Setting --lazy starts the node inside the container:

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",
        "--lazy",
    })
    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) })
}

But there are other problems:

=== RUN   TestDockerIntegration
=== PAUSE TestDockerIntegration
=== CONT  TestDockerIntegration
    integration_test.go:38: docker info
    integration_test.go:39: docker rm -f int_gnoland
    integration_test.go:40: docker build -t gno:integration ../..
    integration_test.go:41: docker run -d --name int_gnoland -w /opt/gno/src/gno.land gno:integration gnoland start --lazy
    integration_test.go:42: waiting...
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: docker logs int_gnoland
    integration_test.go:42: gnoland ready
    integration_test.go:44: docker exec int_gnoland sh -c echo "pass\npass\nsource bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast\n" | gnokey add -recover -insecure-password-stdin test1
    integration_test.go:44: 
            Error Trace:    /Users/zmilos/Work/gno/misc/docker-integration/integration_test.go:119
                                        /Users/zmilos/Work/gno/misc/docker-integration/integration_test.go:51
                                        /Users/zmilos/Work/gno/misc/docker-integration/integration_test.go:44
            Error:          Received unexpected error:
                            exit status 1
            Test:           TestDockerIntegration
            Messages:       Enter a passphrase to encrypt your key to disk:
                            Repeat the passphrase:
                            unable to parse provided password, EOF
--- FAIL: TestDockerIntegration (12.99s)

FAIL

Process finished with the exit code 1
sw360cab commented 6 days ago

almost fixed... Just fighting with gas... Even increasing is not working

  integration_test.go:44: docker exec int_gnoland sh -c echo 'pass' | gnokey maketx addpkg -insecure-password-stdin \
                                -gas-fee 1000000ugnot -gas-wanted 2000000 \
                                -broadcast -chainid dev \
                                -pkgdir /gnoroot/examples/gno.land/r/demo/tests/ \
                                -pkgpath gno.land/r/demo/tests_copy \
                                -deposit 100000000ugnot \
                                test1
---

                                Data: out of gas error
                                Msg Traces:
                                    0  /gnoroot/tm2/pkg/crypto/keys/client/maketx.go:215 - deliver transaction failed: log:out of gas, gasWanted: 2000000, gasUsed: 2078599 location: ReadPerByte
zivkovicmilos commented 6 days ago

Does this even run in the CI?

It screams of an outdated test we should delete

sw360cab commented 6 days ago

I think it is old stuff, but I was curious making them work