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

test: switch e2e test setup to create genesis and configs via Dockertest #1363

Merged
merged 20 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/e2e/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ type internalChain struct {
}

func new(id, dataDir string) (*internalChain, error) {
// return &ChainMeta{
// Id: id,
// DataDir: dataDir,
// }, nil
chainMeta := ChainMeta{
Id: id,
DataDir: dataDir,
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/chain_init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func main() {

b, err := json.Marshal(createdChain)
fileName := fmt.Sprintf("%v/%v-encode", dataDir, chainId)
err2 := os.WriteFile(fileName, b, 0777)
if err2 != nil {
if err = os.WriteFile(fileName, b, 0777); err != nil {
panic(err)
}
}
26 changes: 15 additions & 11 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/osmosis-labs/osmosis/v7/tests/e2e/util"
)

const maxRetries = 10 // max retries for json unmarshalling

type IntegrationTestSuite struct {
suite.Suite

Expand Down Expand Up @@ -258,7 +260,7 @@ func (s *IntegrationTestSuite) runIBCRelayer() {
func (s *IntegrationTestSuite) configureChain(chainId string) {
s.T().Logf("starting e2e infrastructure for chain-id: %s", chainId)
tmpDir, err := ioutil.TempDir("", "osmosis-e2e-testnet-")
s.T().Log(tmpDir)
s.T().Logf("temp directory for chain-id %v: %v", chainId, tmpDir)
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
s.Require().NoError(err)

s.initResource, err = s.dkrPool.RunWithOptions(
Expand All @@ -283,20 +285,22 @@ func (s *IntegrationTestSuite) configureChain(chainId string) {
var newChain chain.Chain

fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId)
s.T().Log(fileName)
s.T().Logf("serialized init file for chain-id %v: %v", chainId, fileName)

attempts := 0
for i := 0; i < 10; i++ {
attempts += i
for i := 0; i < maxRetries; i++ {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
encJson, _ := os.ReadFile(fileName)
err2 := json.Unmarshal(encJson, &newChain)
if err2 != nil {
time.Sleep(1 * time.Second)
} else if err2 != nil && attempts == 10 {
panic(err2)
} else {
err = json.Unmarshal(encJson, &newChain)
if err == nil {
break
}

if i == 10 {
s.Require().NoError(err)
}
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved

if i > 0 {
time.Sleep(1 * time.Second)
}
}
s.chains = append(s.chains, &newChain)

Expand Down