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

added test case TestBasicWindows #1006

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion cmd/e2e-test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ import (
"k8s.io/ingress-gce/pkg/utils/common"
)

func TestWindows(t *testing.T) {
testBasicOS(t, e2e.Windows)
}

func TestBasic(t *testing.T) {
testBasicOS(t, e2e.Linux)
}

func testBasicOS(t *testing.T, os e2e.OS) {
t.Parallel()

port80 := intstr.FromInt(80)
Expand Down Expand Up @@ -64,7 +72,7 @@ func TestBasic(t *testing.T) {

ctx := context.Background()

_, err := e2e.CreateEchoService(s, "service-1", nil)
_, err := e2e.CreateEchoServiceWithOS(s, "service-1", nil, os)
if err != nil {
t.Fatalf("error creating echo service: %v", err)
}
Expand Down
38 changes: 33 additions & 5 deletions pkg/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@ import (
)

const (
echoheadersImage = "gcr.io/k8s-ingress-image-push/ingress-gce-echo-amd64:master"
porterPort = 80
echoheadersImage = "gcr.io/k8s-ingress-image-push/ingress-gce-echo-amd64:master"
echoheadersImageWindows = "gcr.io/gke-windows-testing/ingress-gce-echo-amd64-windows:master"
porterPort = 80
)

type OS int

const (
Linux OS = iota
Windows
)

var ErrSubnetExists = fmt.Errorf("ILB subnet in region already exists")
Expand Down Expand Up @@ -81,9 +89,19 @@ func CreateEchoService(s *Sandbox, name string, annotations map[string]string) (
return EnsureEchoService(s, name, annotations, v1.ServiceTypeNodePort, 1)
}

// CreateEchoServiceWithOS creates the pod and service serving echoheaders
// Todo: (shance) remove this and replace uses with EnsureEchoService()
func CreateEchoServiceWithOS(s *Sandbox, name string, annotations map[string]string, os OS) (*v1.Service, error) {
return ensureEchoService(s, name, annotations, v1.ServiceTypeNodePort, 1, os)
}

// EnsureEchoService that the Echo service with the given description is set up
func EnsureEchoService(s *Sandbox, name string, annotations map[string]string, svcType v1.ServiceType, numReplicas int32) (*v1.Service, error) {
if err := EnsureEchoDeployment(s, name, numReplicas, NoopModify); err != nil {
return ensureEchoService(s, name, annotations, svcType, numReplicas, Linux)
}

func ensureEchoService(s *Sandbox, name string, annotations map[string]string, svcType v1.ServiceType, numReplicas int32, os OS) (*v1.Service, error) {
if err := ensureEchoDeployment(s, name, numReplicas, NoopModify, os); err != nil {
return nil, err
}

Expand Down Expand Up @@ -135,16 +153,27 @@ func EnsureEchoService(s *Sandbox, name string, annotations map[string]string, s

// EnsureEchoDeployment ensures that the Echo deployment with the given description is set up
func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify func(deployment *apps.Deployment)) error {
return ensureEchoDeployment(s, name, numReplicas, modify, Linux)
}

func ensureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify func(deployment *apps.Deployment), os OS) error {
image := echoheadersImage
var nodeSelector map[string]string
if os == Windows {
image = echoheadersImageWindows
nodeSelector = map[string]string{"kubernetes.io/os": "windows"}
}
podTemplate := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{"app": name},
},
Spec: v1.PodSpec{
NodeSelector: nodeSelector,
Containers: []v1.Container{
{
Name: "echoheaders",
Image: echoheadersImage,
Image: image,
Ports: []v1.ContainerPort{
{ContainerPort: 8080, Name: "http-port"},
{ContainerPort: 8443, Name: "https-port"},
Expand Down Expand Up @@ -179,7 +208,6 @@ func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify fun
},
},
}

deployment := &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: apps.DeploymentSpec{
Expand Down