2019-05-25 13:12:27 +00:00
|
|
|
/*
|
2020-07-23 19:55:18 +00:00
|
|
|
Copyright 2020 The Kubernetes Authors.
|
2019-05-25 13:12:27 +00:00
|
|
|
|
|
|
|
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 settings
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
"github.com/onsi/ginkgo"
|
2019-05-25 13:12:27 +00:00
|
|
|
|
|
|
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = framework.IngressNginxDescribe("Configure OpenTracing", func() {
|
|
|
|
f := framework.NewDefaultFramework("enable-opentracing")
|
|
|
|
enableOpentracing := "enable-opentracing"
|
2020-07-23 19:55:18 +00:00
|
|
|
zipkinCollectorHost := "zipkin-collector-host"
|
2019-05-25 13:12:27 +00:00
|
|
|
opentracingOperationName := "opentracing-operation-name"
|
|
|
|
opentracingLocationOperationName := "opentracing-location-operation-name"
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.BeforeEach(func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.NewEchoDeployment()
|
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.AfterEach(func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.It("should not exists opentracing directive", func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(enableOpentracing, "false")
|
|
|
|
|
|
|
|
f.EnsureIngress(framework.NewSingleIngress(enableOpentracing, "/", enableOpentracing, f.Namespace, "http-svc", 80, nil))
|
|
|
|
|
|
|
|
f.WaitForNginxConfiguration(
|
|
|
|
func(cfg string) bool {
|
|
|
|
return !strings.Contains(cfg, "opentracing on")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.It("should exists opentracing directive when is enabled", func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(enableOpentracing, "true")
|
2020-07-23 19:55:18 +00:00
|
|
|
f.UpdateNginxConfigMapData(zipkinCollectorHost, "127.0.0.1")
|
2019-05-25 13:12:27 +00:00
|
|
|
|
|
|
|
f.EnsureIngress(framework.NewSingleIngress(enableOpentracing, "/", enableOpentracing, f.Namespace, "http-svc", 80, nil))
|
|
|
|
|
|
|
|
f.WaitForNginxConfiguration(
|
|
|
|
func(cfg string) bool {
|
|
|
|
return strings.Contains(cfg, "opentracing on")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.It("should not exists opentracing_operation_name directive when is empty", func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(enableOpentracing, "true")
|
2020-07-23 19:55:18 +00:00
|
|
|
f.UpdateNginxConfigMapData(zipkinCollectorHost, "127.0.0.1")
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(opentracingOperationName, "")
|
|
|
|
|
|
|
|
f.EnsureIngress(framework.NewSingleIngress(enableOpentracing, "/", enableOpentracing, f.Namespace, "http-svc", 80, nil))
|
|
|
|
|
|
|
|
f.WaitForNginxConfiguration(
|
|
|
|
func(cfg string) bool {
|
|
|
|
return !strings.Contains(cfg, "opentracing_operation_name")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.It("should exists opentracing_operation_name directive when is configured", func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(enableOpentracing, "true")
|
2020-07-23 19:55:18 +00:00
|
|
|
f.UpdateNginxConfigMapData(zipkinCollectorHost, "127.0.0.1")
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(opentracingOperationName, "HTTP $request_method $uri")
|
|
|
|
|
|
|
|
f.EnsureIngress(framework.NewSingleIngress(enableOpentracing, "/", enableOpentracing, f.Namespace, "http-svc", 80, nil))
|
|
|
|
|
|
|
|
f.WaitForNginxConfiguration(
|
|
|
|
func(cfg string) bool {
|
|
|
|
return strings.Contains(cfg, "opentracing_operation_name \"HTTP $request_method $uri\"")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.It("should not exists opentracing_location_operation_name directive when is empty", func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(enableOpentracing, "true")
|
2020-07-23 19:55:18 +00:00
|
|
|
f.UpdateNginxConfigMapData(zipkinCollectorHost, "127.0.0.1")
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(opentracingLocationOperationName, "")
|
|
|
|
|
|
|
|
f.EnsureIngress(framework.NewSingleIngress(enableOpentracing, "/", enableOpentracing, f.Namespace, "http-svc", 80, nil))
|
|
|
|
|
|
|
|
f.WaitForNginxConfiguration(
|
|
|
|
func(cfg string) bool {
|
|
|
|
return !strings.Contains(cfg, "opentracing_location_operation_name")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-23 19:55:18 +00:00
|
|
|
ginkgo.It("should exists opentracing_location_operation_name directive when is configured", func() {
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(enableOpentracing, "true")
|
2020-07-23 19:55:18 +00:00
|
|
|
f.UpdateNginxConfigMapData(zipkinCollectorHost, "127.0.0.1")
|
2019-05-25 13:12:27 +00:00
|
|
|
f.UpdateNginxConfigMapData(opentracingLocationOperationName, "HTTP $request_method $uri")
|
|
|
|
|
|
|
|
f.EnsureIngress(framework.NewSingleIngress(enableOpentracing, "/", enableOpentracing, f.Namespace, "http-svc", 80, nil))
|
|
|
|
|
|
|
|
f.WaitForNginxConfiguration(
|
|
|
|
func(cfg string) bool {
|
|
|
|
return strings.Contains(cfg, "opentracing_location_operation_name \"HTTP $request_method $uri\"")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|