-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
@@ -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 |
There was a problem hiding this comment.
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
"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))}}, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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")) | ||
|
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
cfg.Babylon.RPCAddr = fmt.Sprintf("http://localhost:%s", babylond.GetPort("26657/tcp")) | ||
cfg.Babylon.GRPCAddr = fmt.Sprintf("https://localhost:%s", babylond.GetPort("9090/tcp")) | ||
|
There was a problem hiding this comment.
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
e2etest/container/container.go
Outdated
Labels: map[string]string{ | ||
"e2e": "babylond", | ||
}, | ||
//User: "root:root", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove or uncomment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
e2etest/container/container.go
Outdated
// jury | ||
_, juryPK = btcec.PrivKeyFromBytes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// jury | |
_, juryPK = btcec.PrivKeyFromBytes( | |
_, covenantPK = btcec.PrivKeyFromBytes( |
We don't use jury any more
"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))}}, |
There was a problem hiding this comment.
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?
e2etest/container/container.go
Outdated
// 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 |
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, depending on config
Seems we can remove |
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