Skip to content

Commit

Permalink
e2e tests are being skipped; INFRASTRUCTURE-* bug; portGen inconsis…
Browse files Browse the repository at this point in the history
…tency bug (#933) (#935)

* Should fail, not skip!

* e2e: fix env variable names

* Fix failing tests in e2e

(cherry picked from commit 73a6c58)

Co-authored-by: Sergio Mena <sergio@informal.systems>
  • Loading branch information
mergify[bot] and sergio-mena committed Jun 9, 2023
1 parent a8adaa4 commit d1b6e9d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
14 changes: 13 additions & 1 deletion test/e2e/pkg/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net"
"os"
"sort"
)

const (
Expand Down Expand Up @@ -43,6 +44,16 @@ type InstanceData struct {
Port uint32 `json:"port"`
}

func sortNodeNames(m Manifest) []string {
// Set up nodes, in alphabetical order (IPs and ports get same order).
nodeNames := []string{}
for name := range m.Nodes {
nodeNames = append(nodeNames, name)
}
sort.Strings(nodeNames)
return nodeNames
}

func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) {
netAddress := dockerIPv4CIDR
if m.IPv6 {
Expand All @@ -61,12 +72,13 @@ func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) {
Network: netAddress,
}
localHostIP := net.ParseIP("127.0.0.1")
for name := range m.Nodes {
for _, name := range sortNodeNames(m) {
ifd.Instances[name] = InstanceData{
IPAddress: ipGen.Next(),
ExtIPAddress: localHostIP,
Port: portGen.Next(),
}

}
return ifd, nil
}
Expand Down
10 changes: 1 addition & 9 deletions test/e2e/pkg/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"math/rand"
"net"
"path/filepath"
"sort"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -184,14 +183,7 @@ func NewTestnetFromManifest(manifest Manifest, file string, ifd InfrastructureDa
testnet.LoadTxSizeBytes = defaultTxSizeBytes
}

// Set up nodes, in alphabetical order (IPs and ports get same order).
nodeNames := []string{}
for name := range manifest.Nodes {
nodeNames = append(nodeNames, name)
}
sort.Strings(nodeNames)

for _, name := range nodeNames {
for _, name := range sortNodeNames(manifest) {
nodeManifest := manifest.Nodes[name]
ind, ok := ifd.Instances[name]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/runner/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Test(testnet *e2e.Testnet, ifd *e2e.InfrastructureData) error {
return err
}
if p := ifd.Path; p != "" {
err = os.Setenv("INFRASTRUCTURE_DATA", p)
err = os.Setenv("INFRASTRUCTURE_FILE", p)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func loadTestnet(t *testing.T) e2e.Testnet {
if !filepath.IsAbs(manifestFile) {
manifestFile = filepath.Join("..", manifestFile)
}
ifdType := os.Getenv("INFRASTRUCTURE_DATA")
ifdType := os.Getenv("INFRASTRUCTURE_TYPE")
ifdFile := os.Getenv("INFRASTRUCTURE_FILE")
if ifdFile == "" && ifdType != "docker" {
t.Skip("INFRASTRUCTURE_DATA not set and INFRASTRUCTURE_TYPE is not docker")
if ifdType != "docker" && ifdFile == "" {
t.Fatalf("INFRASTRUCTURE_FILE not set and INFRASTRUCTURE_TYPE is not 'docker'")
}
testnetCacheMtx.Lock()
defer testnetCacheMtx.Unlock()
Expand Down

0 comments on commit d1b6e9d

Please sign in to comment.