Skip to content

Commit

Permalink
added test case TestBasicWindows that tests the basic ingress for
Browse files Browse the repository at this point in the history
'windows' platform
  • Loading branch information
yliaog committed Jan 30, 2020
1 parent 50924ce commit b857e11
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
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 TestBasicWindows(t *testing.T) {
testBasic(t, "windows")
}

func TestBasic(t *testing.T) {
testBasic(t, "")
}

func testBasic(t *testing.T, os string) {
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.CreateEchoServiceOS(s, "service-1", nil, os)
if err != nil {
t.Fatalf("error creating echo service: %v", err)
}
Expand Down
31 changes: 26 additions & 5 deletions pkg/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ 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
)

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

// CreateEchoService creates the pod and service serving echoheaders
// Todo: (shance) remove this and replace uses with EnsureEchoService()
func CreateEchoServiceOS(s *Sandbox, name string, annotations map[string]string, os string) (*v1.Service, error) {
return ensureEchoServiceOS(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 ensureEchoServiceOS(s, name, annotations, svcType, numReplicas, "")
}

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

Expand Down Expand Up @@ -135,6 +146,14 @@ 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 ensureEchoDeploymentOS(s, name, numReplicas, modify, "")
}

func ensureEchoDeploymentOS(s *Sandbox, name string, numReplicas int32, modify func(deployment *apps.Deployment), os string) error {
image := echoheadersImage
if os == "windows" {
image = echoheadersImageWindows
}
podTemplate := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -144,7 +163,7 @@ func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify fun
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 +198,9 @@ func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify fun
},
},
}

if os == "windows" {
podTemplate.Spec.NodeSelector = map[string]string{"kubernetes.io/os": "windows"}
}
deployment := &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: apps.DeploymentSpec{
Expand Down

0 comments on commit b857e11

Please sign in to comment.