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
22 changes: 11 additions & 11 deletions .github/workflows/publish.yml → .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ name: docker_publish
on:
push:
branches:
- 'main'
- 'main'
tags:
- '*'
- '*'

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/[email protected]
with:
go-version: '1.23'
go-lint-version: 'v1.60.2'
run-unit-tests: true
run-integration-tests: true
run-lint: true
install-dependencies-command: |
sudo apt-get update
sudo apt-get install -y libzmq3-dev
go-version: '1.23'
go-lint-version: 'v1.60.2'
run-unit-tests: true
run-integration-tests: true
run-lint: true
install-dependencies-command: |
sudo apt-get update
sudo apt-get install -y libzmq3-dev


docker_pipeline:
needs: ["lint_test"]
uses: babylonlabs-io/.github/.github/workflows/[email protected]
secrets: inherit
with:
publish: true
publish: true
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ test:
go test -race ./...

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


build-docker:
$(DOCKER) build --tag babylonlabs-io/vigilante -f Dockerfile \
Expand Down
214 changes: 0 additions & 214 deletions e2etest/babylon_node_handler.go

This file was deleted.

16 changes: 10 additions & 6 deletions e2etest/bitcoind_node_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/babylonlabs-io/vigilante/e2etest/container"
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/require"
"os"
"strconv"
Expand Down Expand Up @@ -33,25 +34,22 @@ type BitcoindTestHandler struct {
m *container.Manager
}

func NewBitcoindHandler(t *testing.T) *BitcoindTestHandler {
manager, err := container.NewManager()
require.NoError(t, err)

func NewBitcoindHandler(t *testing.T, manager *container.Manager) *BitcoindTestHandler {
return &BitcoindTestHandler{
t: t,
m: manager,
}
}

func (h *BitcoindTestHandler) Start() {
func (h *BitcoindTestHandler) Start(t *testing.T) *dockertest.Resource {
tempPath, err := os.MkdirTemp("", "vigilante-test-*")
require.NoError(h.t, err)

h.t.Cleanup(func() {
_ = os.RemoveAll(tempPath)
})

_, err = h.m.RunBitcoindResource(tempPath)
bitcoinResource, err := h.m.RunBitcoindResource(t, tempPath)
require.NoError(h.t, err)

h.t.Cleanup(func() {
Expand All @@ -65,6 +63,8 @@ func (h *BitcoindTestHandler) Start() {
}
return err == nil
}, startTimeout, 500*time.Millisecond, "bitcoind did not start")

return bitcoinResource
}

// GetBlockCount retrieves the current number of blocks in the blockchain from the Bitcoind.
Expand Down Expand Up @@ -115,3 +115,7 @@ func (h *BitcoindTestHandler) ImportDescriptors(descriptor string) {
_, _, err := h.m.ExecBitcoindCliCmd(h.t, []string{"importdescriptors", descriptor})
require.NoError(h.t, err)
}

func (h *BitcoindTestHandler) Stop() {
_ = h.m.ClearResources()
}
9 changes: 7 additions & 2 deletions e2etest/container/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ package container
type ImageConfig struct {
BitcoindRepository string
BitcoindVersion string
BabylonRepository string
BabylonVersion string
}

//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

)

// NewImageConfig returns ImageConfig needed for running e2e test.
func NewImageConfig() ImageConfig {
config := ImageConfig{
return ImageConfig{
BitcoindRepository: dockerBitcoindRepository,
BitcoindVersion: dockerBitcoindVersionTag,
BabylonRepository: dockerBabylondRepository,
BabylonVersion: dockerBabylondVersionTag,
}
return config
}
Loading
Loading