Skip to content

Commit

Permalink
wip: removed one debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Nov 8, 2024
1 parent 90af7a6 commit 7d2925a
Show file tree
Hide file tree
Showing 28 changed files with 2,075 additions and 39 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ func NewApp(
paramsclient.ProposalHandler,
},
),
ibctm.ModuleName: ibctm.NewAppModule(),
})
app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.BasicModuleManager.RegisterInterfaces(interfaceRegistry)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ replace (
// Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support
//github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.47.10-iavl-v1-kava.1
//github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.50.10-test-patch 5f9239e3147358ef034bfc4d19aacb34e5ea2064
github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.0.0-20241107161140-9121bca395e2
github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.0.0-20241107170058-27e0ccccc208
//github.com/cosmos/cosmos-sdk => ../cosmos-sdk

//github.com/cosmos/cosmos-sdk/store => cosmossdk.io/store v1.1.1
Expand All @@ -281,7 +281,7 @@ replace (
// Tracking kava-labs/etheremint master branch
// TODO: Tag before release
//github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.21.1-0.20240802224012-586960857184
github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.0.0-20241107030905-d910f315f8c7
github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.0.0-20241107232649-d8ee91e8450e
//github.com/evmos/ethermint => ../ethermint
// See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,10 @@ github.com/kava-labs/cometbft v0.0.0-20241024200036-527d8df9ff12 h1:RqnpnEGEuykj
github.com/kava-labs/cometbft v0.0.0-20241024200036-527d8df9ff12/go.mod h1:5awmm7t/X8LJ+Wd7/TXHcv4hLfFLcexy6fdS9WvOepA=
github.com/kava-labs/cometbft-db v0.0.0-20241007145430-b2740b2e4bed h1:3FNJ3fcD9aA9oOwDphrSEJ8u2kBNj9YoYAwl16UKyv4=
github.com/kava-labs/cometbft-db v0.0.0-20241007145430-b2740b2e4bed/go.mod h1:buPRZKyVp+u5fmwN7tDtOk1zc5xA2z9BJJTy61tNnws=
github.com/kava-labs/cosmos-sdk v0.0.0-20241107161140-9121bca395e2 h1:YUetmupzuNF+w7yrQYG6xzkA87wzamiq3KjzORohj8Y=
github.com/kava-labs/cosmos-sdk v0.0.0-20241107161140-9121bca395e2/go.mod h1:Yf8jj8R5+9NWCbdot0IMId92WeAIF22Thc/pRR2hSoI=
github.com/kava-labs/ethermint v0.0.0-20241107030905-d910f315f8c7 h1:OfO2y640jBDjXC5K399dZsSkryx3B61s4BDpcCggjDY=
github.com/kava-labs/ethermint v0.0.0-20241107030905-d910f315f8c7/go.mod h1:dFh15Ndobz1zWqWcJm9ML+0BnMt5m8gS+MhVUcAGLpg=
github.com/kava-labs/cosmos-sdk v0.0.0-20241107170058-27e0ccccc208 h1:0Z/vypO858xcywSSzxuDsuFW+CuuxeE+8XR1jyMM7qQ=
github.com/kava-labs/cosmos-sdk v0.0.0-20241107170058-27e0ccccc208/go.mod h1:Yf8jj8R5+9NWCbdot0IMId92WeAIF22Thc/pRR2hSoI=
github.com/kava-labs/ethermint v0.0.0-20241107232649-d8ee91e8450e h1:79mJSoWItAG2gPLOzVfdRJnMWy3vwAPdnahjh3jmUno=
github.com/kava-labs/ethermint v0.0.0-20241107232649-d8ee91e8450e/go.mod h1:Vulovod3ZhLTCfs9RkILIDK8WSDyYhnEp665kTRv530=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
2 changes: 1 addition & 1 deletion modules checked.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ E2E tests:

| File | Status | Notes
|----------------------------------------------------------------------------------------|-----|-------------------------------------------------------------------------------------------------|
| e2e_community_update_params_test.go | | TestCommunityUpdateParams_Authority |
| e2e_community_update_params_test.go | | |
| e2e_convert_cosmos_coins_test.go | | TestConvertCosmosCoins_ForbiddenERC20Calls, TestConvertCosmosCoins_ERC20Magic |
| e2e_evm_contracts_test.go || |
| e2e_grpc_client_query_test.go || |
Expand Down
1 change: 1 addition & 0 deletions tests/e2e-ibc/chainconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func DefaultKavaChainConfig(chainId string) ibc.ChainConfig {
kavaImageTag := os.Getenv("KAVA_TAG")
if kavaImageTag == "" {
kavaImageTag = "v0.26.0-rocksdb"
//kavaImageTag = "local"
}

// app.toml overrides
Expand Down
56 changes: 56 additions & 0 deletions tests/e2e-ibc/dockerutil/busybox.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package dockerutil

import (
"context"
"fmt"
"io"
"sync"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
)

// Allow multiple goroutines to check for busybox
// by using a protected package-level variable.
//
// A mutex allows for retries upon error, if we ever need that;
// whereas a sync.Once would not be simple to retry.
var (
ensureBusyboxMu sync.Mutex
hasBusybox bool
)

const busyboxRef = "busybox:stable"

func ensureBusybox(ctx context.Context, cli *client.Client) error {
ensureBusyboxMu.Lock()
defer ensureBusyboxMu.Unlock()

if hasBusybox {
return nil
}

images, err := cli.ImageList(ctx, types.ImageListOptions{
Filters: filters.NewArgs(filters.Arg("reference", busyboxRef)),
})
if err != nil {
return fmt.Errorf("listing images to check busybox presence: %w", err)
}

if len(images) > 0 {
hasBusybox = true
return nil
}

rc, err := cli.ImagePull(ctx, busyboxRef, types.ImagePullOptions{})
if err != nil {
return err
}

_, _ = io.Copy(io.Discard, rc)
_ = rc.Close()

hasBusybox = true
return nil
}
181 changes: 181 additions & 0 deletions tests/e2e-ibc/dockerutil/container_lifecycle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
package dockerutil

import (
"context"
"fmt"
"net"
"strings"

dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
dockerclient "github.com/docker/docker/client"
"github.com/docker/docker/errdefs"
"github.com/docker/go-connections/nat"
"go.uber.org/zap"

"github.com/strangelove-ventures/interchaintest/v8/ibc"
)

type ContainerLifecycle struct {
log *zap.Logger
client *dockerclient.Client
containerName string
id string
preStartListeners Listeners
}

func NewContainerLifecycle(log *zap.Logger, client *dockerclient.Client, containerName string) *ContainerLifecycle {
return &ContainerLifecycle{
log: log,
client: client,
containerName: containerName,
}
}

func (c *ContainerLifecycle) CreateContainer(
ctx context.Context,
testName string,
networkID string,
image ibc.DockerImage,
ports nat.PortMap,
volumeBinds []string,
mounts []mount.Mount,
hostName string,
cmd []string,
env []string,
) error {
imageRef := image.Ref()
c.log.Info(
"Will run command",
zap.String("image", imageRef),
zap.String("container", c.containerName),
zap.String("command", strings.Join(cmd, " ")),
)

pS := nat.PortSet{}
for k := range ports {
pS[k] = struct{}{}
}

pb, listeners, err := GeneratePortBindings(ports)
if err != nil {
return fmt.Errorf("failed to generate port bindings: %w", err)
}

c.preStartListeners = listeners

cc, err := c.client.ContainerCreate(
ctx,
&container.Config{
Image: imageRef,

Entrypoint: []string{},
Cmd: cmd,
Env: env,

Hostname: hostName,

Labels: map[string]string{CleanupLabel: testName},

ExposedPorts: pS,
},
&container.HostConfig{
Binds: volumeBinds,
PortBindings: pb,
PublishAllPorts: true,
AutoRemove: false,
DNS: []string{},
Mounts: mounts,
},
&network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
networkID: {},
},
},
nil,
c.containerName,
)
if err != nil {
listeners.CloseAll()
c.preStartListeners = []net.Listener{}
return err
}
c.id = cc.ID
return nil
}

func (c *ContainerLifecycle) StartContainer(ctx context.Context) error {
// lock port allocation for the time between freeing the ports from the
// temporary listeners to the consumption of the ports by the container
mu.RLock()
defer mu.RUnlock()

c.preStartListeners.CloseAll()
c.preStartListeners = []net.Listener{}

if err := StartContainer(ctx, c.client, c.id); err != nil {
return err
}

c.log.Info("Container started", zap.String("container", c.containerName))

return nil
}

func (c *ContainerLifecycle) PauseContainer(ctx context.Context) error {
return c.client.ContainerPause(ctx, c.id)
}

func (c *ContainerLifecycle) UnpauseContainer(ctx context.Context) error {
return c.client.ContainerUnpause(ctx, c.id)
}

func (c *ContainerLifecycle) StopContainer(ctx context.Context) error {
var timeout container.StopOptions
timeoutSec := 30
timeout.Timeout = &timeoutSec

return c.client.ContainerStop(ctx, c.id, timeout)
}

func (c *ContainerLifecycle) RemoveContainer(ctx context.Context) error {
err := c.client.ContainerRemove(ctx, c.id, dockertypes.ContainerRemoveOptions{
Force: true,
RemoveVolumes: true,
})
if err != nil && !errdefs.IsNotFound(err) {
return fmt.Errorf("remove container %s: %w", c.containerName, err)
}
return nil
}

func (c *ContainerLifecycle) ContainerID() string {
return c.id
}

func (c *ContainerLifecycle) GetHostPorts(ctx context.Context, portIDs ...string) ([]string, error) {
cjson, err := c.client.ContainerInspect(ctx, c.id)
if err != nil {
return nil, err
}
ports := make([]string, len(portIDs))
for i, p := range portIDs {
ports[i] = GetHostPort(cjson, p)
}
return ports, nil
}

// Running will inspect the container and check its state to determine if it is currently running.
// If the container is running nil will be returned, otherwise an error is returned.
func (c *ContainerLifecycle) Running(ctx context.Context) error {
cjson, err := c.client.ContainerInspect(ctx, c.id)
if err != nil {
return err
}
if cjson.State.Running {
return nil
}
return fmt.Errorf("container with name %s and id %s is not running", c.containerName, c.id)
}
2 changes: 2 additions & 0 deletions tests/e2e-ibc/dockerutil/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package dockerutil contains helpers for interacting with Docker containers.
package dockerutil
32 changes: 32 additions & 0 deletions tests/e2e-ibc/dockerutil/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package dockerutil

import (
"fmt"
"io"
"os"
)

func CopyFile(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
}

if !sourceFileStat.Mode().IsRegular() {
return 0, fmt.Errorf("%s is not a regular file", src)
}

source, err := os.Open(src)
if err != nil {
return 0, err
}
defer source.Close()

destination, err := os.Create(dst)
if err != nil {
return 0, err
}
defer destination.Close()
nBytes, err := io.Copy(destination, source)
return nBytes, err
}
Loading

0 comments on commit 7d2925a

Please sign in to comment.