Skip to content

Commit

Permalink
Add createIlbSubnet flag to ilb e2e tests
Browse files Browse the repository at this point in the history
Now used in addition to -network since all ilb tests will need -network
for GCLBForVIP()
  • Loading branch information
spencerhance committed Dec 7, 2019
1 parent e3fe2c5 commit e0a988c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions cmd/e2e-test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
destroySandboxes bool
handleSIGINT bool
gceEndpointOverride string
createIlbSubnet bool
}

Framework *e2e.Framework
Expand All @@ -64,11 +65,12 @@ func init() {
flag.BoolVar(&flags.inCluster, "inCluster", false, "set to true if running in the cluster")
flag.StringVar(&flags.project, "project", "", "GCP project")
flag.StringVar(&flags.region, "region", "", "GCP Region (e.g. us-central1)")
flag.StringVar(&flags.network, "network", "", "GCP network name (e.g. default) to use for ilb subnet")
flag.StringVar(&flags.network, "network", "", "GCP network name (e.g. default)")
flag.Int64Var(&flags.seed, "seed", -1, "random seed")
flag.BoolVar(&flags.destroySandboxes, "destroySandboxes", true, "set to false to leave sandboxed resources for debugging")
flag.BoolVar(&flags.handleSIGINT, "handleSIGINT", true, "catch SIGINT to perform clean")
flag.StringVar(&flags.gceEndpointOverride, "gce-endpoint-override", "", "If set, talks to a different GCE API Endpoint. By default it talks to https://www.googleapis.com/compute/v1/")
flag.BoolVar(&flags.createIlbSubnet, "createIlbSubnet", false, "If set, creates a proxy subnet for the L7 ILB")
}

// TestMain is the entrypoint for the end-to-end test suite. This is where
Expand All @@ -89,9 +91,9 @@ func TestMain(m *testing.M) {
fmt.Println("-region must be set to the region of the cluster")
os.Exit(1)
}

if flags.network == "" {
klog.Info("No network provided, will not create ILB Subnet")
// TODO(shance): Make this a required flag, error out here
fmt.Println("-network must be set to the network of the cluster")
}

fmt.Printf("Version: %q, Commit: %q\n", version.Version, version.GitCommit)
Expand Down Expand Up @@ -123,6 +125,7 @@ func TestMain(m *testing.M) {
Seed: flags.seed,
DestroySandboxes: flags.destroySandboxes,
GceEndpointOverride: flags.gceEndpointOverride,
CreateIlbSubnet: flags.createIlbSubnet,
})
if flags.handleSIGINT {
Framework.CatchSIGINT()
Expand Down
4 changes: 2 additions & 2 deletions pkg/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ func DeleteGCPAddress(s *Sandbox, name string) error {

// CreateILBSubnet creates the ILB subnet
func CreateILBSubnet(s *Sandbox) error {
klog.V(3).Info("CreateILBSubnet()")
klog.V(4).Info("CreateILBSubnet()")

// If no network is provided, we don't try to create the subnet
if s.f.Network == "" {
if s.f.Network == "" || !s.f.CreateILBSubnet {
return ErrSubnetExists
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Options struct {
Seed int64
DestroySandboxes bool
GceEndpointOverride string
CreateIlbSubnet bool
}

// NewFramework returns a new test framework to run.
Expand All @@ -69,6 +70,7 @@ func NewFramework(config *rest.Config, options Options) *Framework {
Cloud: theCloud,
Rand: rand.New(rand.NewSource(options.Seed)),
destroySandboxes: options.DestroySandboxes,
CreateILBSubnet: options.CreateIlbSubnet,
}
f.statusManager = NewStatusManager(f)
return f
Expand All @@ -87,6 +89,7 @@ type Framework struct {
statusManager *StatusManager

destroySandboxes bool
CreateILBSubnet bool

lock sync.Mutex
sandboxes []*Sandbox
Expand Down

0 comments on commit e0a988c

Please sign in to comment.