From 341cabec0e50ba0256cb2839434a35cfd1a199c4 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Tue, 18 Oct 2022 15:39:16 -0400 Subject: [PATCH] add 'provider' field to the infrastructure data file to disable ip range check --- test/e2e/pkg/infrastructure.go | 10 ++++++++-- test/e2e/pkg/testnet.go | 24 +++++++++++++++++++----- test/e2e/runner/main.go | 1 - 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/test/e2e/pkg/infrastructure.go b/test/e2e/pkg/infrastructure.go index 944225b82..fffe50f3e 100644 --- a/test/e2e/pkg/infrastructure.go +++ b/test/e2e/pkg/infrastructure.go @@ -11,6 +11,11 @@ import ( // infrastructure that is to be used for running a testnet. type InfrastructureData struct { + // Provider is the name of infrastructure provider backing the testnet. + // For example, 'docker' if it is running locally in a docker network or + // 'digital-ocean', 'aws', 'google', etc. if it is from a cloud provider. + Provider string `json:"provider"` + // Instances is a map of all of the machine instances on which to run // processes for a testnet. // The key of the map is the name of the instance, which each must correspond @@ -25,9 +30,9 @@ type InstanceData struct { } func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) { - netAddress := networkIPv4 + netAddress := dockerIPv4CIDR if m.IPv6 { - netAddress = networkIPv6 + netAddress = dockerIPv6CIDR } _, ipNet, err := net.ParseCIDR(netAddress) if err != nil { @@ -35,6 +40,7 @@ func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) { } ipGen := newIPGenerator(ipNet) ifd := InfrastructureData{ + Provider: "docker", Instances: make(map[string]InstanceData), } for name := range m.Nodes { diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 08365f267..d0cb4aac4 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -21,8 +21,11 @@ import ( const ( randomSeed int64 = 2308084734268 proxyPortFirst uint32 = 5701 - networkIPv4 = "10.186.73.0/24" - networkIPv6 = "fd80:b10c::/48" + dockerIPv4CIDR = "10.186.73.0/24" + dockerIPv6CIDR = "fd80:b10c::/48" + + globalIPv4CIDR = "0.0.0.0/0" + globalIPv6CIDR = "0:0::/0" ) type ( @@ -108,9 +111,20 @@ func LoadTestnet(file string, ifd InfrastructureData) (*Testnet, error) { dir := strings.TrimSuffix(file, filepath.Ext(file)) // Set up resource generators. These must be deterministic. - netAddress := networkIPv4 - if manifest.IPv6 { - netAddress = networkIPv6 + var netAddress string + switch ifd.Provider { + case "docker": + netAddress = dockerIPv4CIDR + if manifest.IPv6 { + netAddress = dockerIPv6CIDR + } + default: + // TODO(williambanfield): add list of CIDR blocks to the infrastructure + // data struct to allow tighter validation of IP addresses. + netAddress = globalIPv4CIDR + if manifest.IPv6 { + netAddress = globalIPv6CIDR + } } _, ipNet, err := net.ParseCIDR(netAddress) if err != nil { diff --git a/test/e2e/runner/main.go b/test/e2e/runner/main.go index 976a52d75..0dc376e9f 100644 --- a/test/e2e/runner/main.go +++ b/test/e2e/runner/main.go @@ -69,7 +69,6 @@ func NewCLI() *CLI { return errors.New("'--infrastructure-data' must be set when using the 'digital-ocean' infrastructure-type") } ifd, err = e2e.InfrastructureDataFromFile(p) - // TODO(williambanfield): add a section that implements the 'digital-ocean' infrastructure-type default: return fmt.Errorf("unknown infrastructure type '%s'", t) }