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

more e2eservice.TestJig cleanups #83549

Merged
merged 4 commits into from
Oct 18, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions test/e2e/apps/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,12 @@ func testRollingUpdateDeploymentWithLocalTrafficLoadBalancer(f *framework.Framew
framework.ExpectNoError(err)

framework.Logf("Creating a service %s with type=LoadBalancer and externalTrafficPolicy=Local in namespace %s", name, ns)
jig := e2eservice.NewTestJig(c, name)
jig := e2eservice.NewTestJig(c, ns, name)
jig.Labels = podLabels
service := jig.CreateLoadBalancerService(ns, name, e2eservice.LoadBalancerCreateTimeoutDefault, func(svc *v1.Service) {
service, err := jig.CreateLoadBalancerService(e2eservice.LoadBalancerCreateTimeoutDefault, func(svc *v1.Service) {
svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyTypeLocal
})
framework.ExpectNoError(err)

lbNameOrAddress := e2eservice.GetIngressPoint(&service.Status.LoadBalancer.Ingress[0])
svcPort := int(service.Spec.Ports[0].Port)
Expand All @@ -921,13 +922,15 @@ func testRollingUpdateDeploymentWithLocalTrafficLoadBalancer(f *framework.Framew
defer close(done)
go func() {
defer ginkgo.GinkgoRecover()
expectedNodes := jig.GetEndpointNodeNames(service)
expectedNodes, err := jig.GetEndpointNodeNames()
framework.ExpectNoError(err)
// The affinity policy should ensure that before an old pod is
// deleted, a new pod will have been created on the same node.
// Thus the set of nodes with local endpoints for the service
// should remain unchanged.
wait.Until(func() {
actualNodes := jig.GetEndpointNodeNames(service)
actualNodes, err := jig.GetEndpointNodeNames()
framework.ExpectNoError(err)
if !actualNodes.Equal(expectedNodes) {
framework.Logf("The set of nodes with local endpoints changed; started with %v, now have %v", expectedNodes.List(), actualNodes.List())
failed <- struct{}{}
Expand Down
9 changes: 5 additions & 4 deletions test/e2e/framework/ingress/ingress_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,17 +841,18 @@ func (cont *NginxIngressController) Init() {
// --publish-service flag (see <IngressManifestPath>/nginx/rc.yaml) to make it work in private
// clusters, i.e. clusters where nodes don't have public IPs.
framework.Logf("Creating load balancer service for nginx ingress controller")
serviceJig := e2eservice.NewTestJig(cont.Client, "nginx-ingress-lb")
serviceJig.CreateTCPServiceOrFail(cont.Ns, func(svc *v1.Service) {
serviceJig := e2eservice.NewTestJig(cont.Client, cont.Ns, "nginx-ingress-lb")
_, err := serviceJig.CreateTCPService(func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
svc.Spec.Selector = map[string]string{"k8s-app": "nginx-ingress-lb"}
svc.Spec.Ports = []v1.ServicePort{
{Name: "http", Port: 80},
{Name: "https", Port: 443},
{Name: "stats", Port: 18080}}
})
cont.lbSvc = serviceJig.WaitForLoadBalancerOrFail(cont.Ns, "nginx-ingress-lb", e2eservice.GetServiceLoadBalancerCreationTimeout(cont.Client))
serviceJig.SanityCheckService(cont.lbSvc, v1.ServiceTypeLoadBalancer)
framework.ExpectNoError(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you please add an annotation to the error assertion, for example:

framework.ExpectNoError(err, "failed to create a load balancer service for nginx ingress controller")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error itself already says all of that though ("failed to create TCP service 'nginx-ingress-lb': ...")...

cont.lbSvc, err = serviceJig.WaitForLoadBalancer(e2eservice.GetServiceLoadBalancerCreationTimeout(cont.Client))
framework.ExpectNoError(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, please add an annotation, e.g.,

framework.ExpectNoError(err, "timed out waiting for load balancer")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise, the actual error would be "timed out waiting for service 'nginx-ingress-lb' to have a load balancer"


read := func(file string) string {
return string(testfiles.ReadOrDie(filepath.Join(IngressManifestPath, "nginx", file)))
Expand Down
1 change: 0 additions & 1 deletion test/e2e/framework/service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
importpath = "k8s.io/kubernetes/test/e2e/framework/service",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/core:go_default_library",
"//pkg/registry/core/service/portallocator:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",
Expand Down