Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e): run babylond in docker #52

Merged
merged 19 commits into from
Sep 18, 2024
Merged

chore(e2e): run babylond in docker #52

merged 19 commits into from
Sep 18, 2024

Conversation

Lazar955
Copy link
Member

@Lazar955 Lazar955 commented Sep 17, 2024

Instead of managing babylond as a process, we run it in a Docker container.
This will make e2e tests more consistent as bitcoind is also running in Docker and will enable us to run tests in parallel with t.Parallel (next PR).

References issue

@@ -50,7 +50,7 @@ test:

test-e2e:
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG);
go test -race -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e
go test -race -mod=readonly --failfast -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure we fail the test as soon as one of them fails, no need to waste CI

Comment on lines +176 to +181
"8332/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"8333/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"28332/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"28333/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18443/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18444/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we will be running multiple instances of both bitcoind and Babylon, ensure we use random ports so they don't clash

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why would we be running multiple instances? For e2e in vigilante, a single pair of bitcoind and babylond should be enough, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but I feel like e2e tests should be isolated to confirm state, rather than tests possibly conflicting with one another

Copy link
Member Author

@Lazar955 Lazar955 Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that when we start running tests with t.Parallel() we will be spawning bitcoind and Babylon container per e2e test, this ensures that ports won't conflict. There's no need for these tests to be sequential if we can run them in parallel

Comment on lines +97 to +99
cfg.BTC.Endpoint = fmt.Sprintf("127.0.0.1:%s", bitcoind.GetPort("18443/tcp"))
cfg.BTC.ZmqSeqEndpoint = fmt.Sprintf("tcp:// 127.0.0.1:%s", bitcoind.GetPort("28333/tcp"))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obtain relevant ports, based on the mapping of internal ones

require.NoError(t, err)

// create Babylon client
cfg.Babylon.KeyDirectory = bh.GetNodeDataDir()
cfg.Babylon.KeyDirectory = filepath.Join(tmpDir, "node0", "babylond")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we expose this inside of our babylon container

Comment on lines +143 to +145
cfg.Babylon.RPCAddr = fmt.Sprintf("http://localhost:%s", babylond.GetPort("26657/tcp"))
cfg.Babylon.GRPCAddr = fmt.Sprintf("https://localhost:%s", babylond.GetPort("9090/tcp"))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get the assigned ports, same as above

Labels: map[string]string{
"e2e": "babylond",
},
//User: "root:root",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove or uncomment?

Copy link
Contributor

@RafilxTenfen RafilxTenfen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Some questions:

}

//nolint:deadcode
const (
dockerBitcoindRepository = "lncm/bitcoind"
dockerBitcoindVersionTag = "v27.0"
dockerBabylondRepository = "babylonlabs/babylond"
dockerBabylondVersionTag = "8e0222804ed19b18d74d599b80baa18f05e87d8a" // this is built from commit b1e255a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this should be manually updated to be consistent with the version in go.mod, correct? How to get the docker version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a tag, like v0.9.3, but our CI wasn't setup at the time to build for arm64. So yes, it should reflect go mod version

Comment on lines 28 to 29
// jury
_, juryPK = btcec.PrivKeyFromBytes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// jury
_, juryPK = btcec.PrivKeyFromBytes(
_, covenantPK = btcec.PrivKeyFromBytes(

We don't use jury any more

Comment on lines +176 to +181
"8332/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"8333/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"28332/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"28333/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18443/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18444/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why would we be running multiple instances? For e2e in vigilante, a single pair of bitcoind and babylond should be enough, no?

// ClearResources removes all outstanding Docker resources created by the Manager.
func (m *Manager) ClearResources() error {
for _, resource := range m.resources {
if err := m.pool.Purge(resource); err != nil {
return err
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we know there's an error here?

passphrase := "pass"
_ = btcHandler.CreateWallet("default", passphrase)

cfg := defaultVigilanteConfig()

cfg.BTC.Endpoint = fmt.Sprintf("127.0.0.1:%s", bitcoind.GetPort("18443/tcp"))
cfg.BTC.ZmqSeqEndpoint = fmt.Sprintf("tcp:// 127.0.0.1:%s", bitcoind.GetPort("28333/tcp"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still support zmq?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, depending on config

@gitferry
Copy link
Member

Seems we can remove tools/?

@Lazar955 Lazar955 merged commit 8a4bdf5 into main Sep 18, 2024
8 checks passed
@Lazar955 Lazar955 deleted the lazar/babylon-docker branch September 18, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants