kubernetes/test/e2e/framework/providers/gce/firewall_test.go
Patrick Ohly 8b17db7e0c e2e: modular framework
Not all users of the E2E framework want to run cloud-provider specific
tests. By splitting out the code it becomes possible to decide in
a E2E test suite which providers are supported.

This is achieved in two ways:
- the framework calls certain functions through a provider
  interface instead of calling specific cloud provider functions
  directly
- tests that are cloud-provider specific directly import the
  new provider packages

The ingress test utilities are only needed by a few tests. Splitting
them out into a separate package makes the framework simpler for test
suites not using those tests.

Fixes: #66649
2018-10-11 11:16:11 +02:00

55 lines
1.5 KiB
Go

/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package gce
import "testing"
func TestIsPortsSubset(t *testing.T) {
tc := map[string]struct {
required []string
coverage []string
expectErr bool
}{
"Single port coverage": {
required: []string{"tcp/50"},
coverage: []string{"tcp/50", "tcp/60", "tcp/70"},
},
"Port range coverage": {
required: []string{"tcp/50"},
coverage: []string{"tcp/20-30", "tcp/45-60"},
},
"Multiple Port range coverage": {
required: []string{"tcp/50", "tcp/29", "tcp/46"},
coverage: []string{"tcp/20-30", "tcp/45-60"},
},
"Not covered": {
required: []string{"tcp/50"},
coverage: []string{"udp/50", "tcp/49", "tcp/51-60"},
expectErr: true,
},
}
for name, c := range tc {
t.Run(name, func(t *testing.T) {
gotErr := isPortsSubset(c.required, c.coverage)
if c.expectErr != (gotErr != nil) {
t.Errorf("isPortsSubset(%v, %v) = %v, wanted err? %v", c.required, c.coverage, gotErr, c.expectErr)
}
})
}
}