Lint go code (#5132)
This commit is contained in:
parent
f6c0faa6eb
commit
57fcbdfb73
7 changed files with 60 additions and 49 deletions
|
@ -19,7 +19,7 @@ package annotations
|
|||
import (
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
@ -27,11 +27,11 @@ import (
|
|||
var _ = framework.DescribeAnnotation("server-snippet", func() {
|
||||
f := framework.NewDefaultFramework("serversnippet")
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
})
|
||||
|
||||
It(`add valid directives to server via server snippet"`, func() {
|
||||
ginkgo.It(`add valid directives to server via server snippet"`, func() {
|
||||
host := "serversnippet.foo.com"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/server-snippet": `
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/gavv/httpexpect.v2"
|
||||
|
@ -34,8 +35,6 @@ import (
|
|||
"k8s.io/client-go/kubernetes"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/klog"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
// RequestScheme define a scheme used in a test request.
|
||||
|
@ -301,6 +300,7 @@ func (f *Framework) SetNginxConfigMapData(cmData map[string]string) {
|
|||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
||||
// CreateConfigMap creates a new configmap in the current namespace
|
||||
func (f *Framework) CreateConfigMap(name string, data map[string]string) {
|
||||
_, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(&v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
@ -349,10 +349,13 @@ func (f *Framework) DeleteNGINXPod(grace int64) {
|
|||
assert.Nil(ginkgo.GinkgoT(), err, "while waiting for ingress nginx pod to come up again")
|
||||
}
|
||||
|
||||
// HTTPTestClient returns a new httpexpect client for end-to-end HTTP testing.
|
||||
func (f *Framework) HTTPTestClient() *httpexpect.Expect {
|
||||
return f.newTestClient(nil)
|
||||
}
|
||||
|
||||
// HTTPTestClientWithTLSConfig returns a new httpexpect client for end-to-end
|
||||
// HTTP testing with a custom TLS configuration.
|
||||
func (f *Framework) HTTPTestClientWithTLSConfig(config *tls.Config) *httpexpect.Expect {
|
||||
return f.newTestClient(config)
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -46,7 +45,7 @@ func nowStamp() string {
|
|||
}
|
||||
|
||||
func log(level string, format string, args ...interface{}) {
|
||||
fmt.Fprintf(GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
|
||||
fmt.Fprintf(ginkgo.GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
|
||||
}
|
||||
|
||||
// Logf logs to the INFO logs.
|
||||
|
@ -58,14 +57,14 @@ func Logf(format string, args ...interface{}) {
|
|||
func Failf(format string, args ...interface{}) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
log("INFO", msg)
|
||||
Fail(nowStamp()+": "+msg, 1)
|
||||
ginkgo.Fail(nowStamp()+": "+msg, 1)
|
||||
}
|
||||
|
||||
// Skipf logs to the INFO logs and skips the test.
|
||||
func Skipf(format string, args ...interface{}) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
log("INFO", msg)
|
||||
Skip(nowStamp() + ": " + msg)
|
||||
ginkgo.Skip(nowStamp() + ": " + msg)
|
||||
}
|
||||
|
||||
// RestclientConfig deserializes the contents of a kubeconfig file into a Config object.
|
||||
|
|
|
@ -183,6 +183,7 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() {
|
|||
|
||||
ginkgo.It("falls back to using default certificate when secret gets deleted without reloading", func() {
|
||||
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
|
||||
assert.Nil(ginkgo.GinkgoT(), err)
|
||||
|
||||
ensureHTTPSRequest(f, fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host)
|
||||
|
||||
|
|
|
@ -17,83 +17,94 @@ limitations under the License.
|
|||
package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
var _ = framework.DescribeSetting("Settings - hash size", func() {
|
||||
var _ = framework.DescribeSetting("hash size", func() {
|
||||
f := framework.NewDefaultFramework("hash-size")
|
||||
|
||||
host := "hash-size"
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)
|
||||
f.EnsureIngress(ing)
|
||||
})
|
||||
Context("Check server names hash size", func() {
|
||||
It("should set server_names_hash_bucket_size", func() {
|
||||
|
||||
ginkgo.Context("Check server names hash size", func() {
|
||||
|
||||
ginkgo.It("should set server_names_hash_bucket_size", func() {
|
||||
f.UpdateNginxConfigMapData("server-name-hash-bucket-size", "512")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`server_names_hash_bucket_size 512;`))
|
||||
return strings.Contains(server, "server_names_hash_bucket_size 512;")
|
||||
})
|
||||
})
|
||||
|
||||
It("should set server_names_hash_max_size", func() {
|
||||
ginkgo.It("should set server_names_hash_max_size", func() {
|
||||
f.UpdateNginxConfigMapData("server-name-hash-max-size", "4096")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`server_names_hash_max_size 4096;`))
|
||||
return strings.Contains(server, "server_names_hash_max_size 4096;")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Context("Check proxy header hash size", func() {
|
||||
It("should set proxy-headers-hash-bucket-size", func() {
|
||||
ginkgo.Context("Check proxy header hash size", func() {
|
||||
|
||||
ginkgo.It("should set proxy-headers-hash-bucket-size", func() {
|
||||
f.UpdateNginxConfigMapData("proxy-headers-hash-bucket-size", "512")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`proxy_headers_hash_bucket_size 512;`))
|
||||
return strings.Contains(server, "proxy_headers_hash_bucket_size 512;")
|
||||
})
|
||||
})
|
||||
It("should set proxy-headers-hash-max-size", func() {
|
||||
|
||||
ginkgo.It("should set proxy-headers-hash-max-size", func() {
|
||||
f.UpdateNginxConfigMapData("proxy-headers-hash-max-size", "4096")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`proxy_headers_hash_max_size 4096;`))
|
||||
return strings.Contains(server, "proxy_headers_hash_max_size 4096;")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
Context("Check the variable hash size", func() {
|
||||
It("should set variables-hash-bucket-size", func() {
|
||||
|
||||
ginkgo.Context("Check the variable hash size", func() {
|
||||
|
||||
ginkgo.It("should set variables-hash-bucket-size", func() {
|
||||
f.UpdateNginxConfigMapData("variables-hash-bucket-size", "512")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`variables_hash_bucket_size 512;`))
|
||||
return strings.Contains(server, "variables_hash_bucket_size 512;")
|
||||
})
|
||||
})
|
||||
It("should set variables-hash-max-size", func() {
|
||||
|
||||
ginkgo.It("should set variables-hash-max-size", func() {
|
||||
f.UpdateNginxConfigMapData("variables-hash-max-size", "512")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`variables_hash_max_size 512;`))
|
||||
return strings.Contains(server, "variables_hash_max_size 512;")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Context("Check the map hash size", func() {
|
||||
It("should set vmap-hash-bucket-size", func() {
|
||||
ginkgo.Context("Check the map hash size", func() {
|
||||
|
||||
ginkgo.It("should set vmap-hash-bucket-size", func() {
|
||||
f.UpdateNginxConfigMapData("map-hash-bucket-size", "512")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`map_hash_bucket_size 512;`))
|
||||
return strings.Contains(server, "map_hash_bucket_size 512;")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -20,23 +20,22 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
var _ = framework.DescribeSetting("Settings - keep alive", func() {
|
||||
var _ = framework.DescribeSetting("keep-alive keep-alive-requests", func() {
|
||||
f := framework.NewDefaultFramework("keep-alive")
|
||||
|
||||
host := "keep-alive"
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)
|
||||
f.EnsureIngress(ing)
|
||||
})
|
||||
|
||||
It("should set keepalive_timeout", func() {
|
||||
ginkgo.It("should set keepalive_timeout", func() {
|
||||
f.UpdateNginxConfigMapData("keep-alive", "140")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
|
@ -44,12 +43,11 @@ var _ = framework.DescribeSetting("Settings - keep alive", func() {
|
|||
})
|
||||
})
|
||||
|
||||
It("should set keepalive_requests", func() {
|
||||
ginkgo.It("should set keepalive_requests", func() {
|
||||
f.UpdateNginxConfigMapData("keep-alive-requests", "200")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`keepalive_requests 200;`))
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
|
|
@ -17,44 +17,43 @@ limitations under the License.
|
|||
package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
var _ = framework.DescribeSetting("Settings - reuse port", func() {
|
||||
var _ = framework.DescribeSetting("reuse-port", func() {
|
||||
f := framework.NewDefaultFramework("reuse-port")
|
||||
|
||||
host := "reuse-port"
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)
|
||||
f.EnsureIngress(ing)
|
||||
})
|
||||
|
||||
It("reuse port should be enabled by default", func() {
|
||||
ginkgo.It("reuse port should be enabled by default", func() {
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`reuseport`))
|
||||
return strings.Contains(server, "reuseport")
|
||||
})
|
||||
})
|
||||
|
||||
It("reuse port should be disabled", func() {
|
||||
ginkgo.It("reuse port should be disabled", func() {
|
||||
f.UpdateNginxConfigMapData("reuse-port", "false")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return !strings.Contains(server, fmt.Sprintf(`reuseport`))
|
||||
return !strings.Contains(server, "reuseport")
|
||||
})
|
||||
})
|
||||
|
||||
It("reuse port should be enabled", func() {
|
||||
ginkgo.It("reuse port should be enabled", func() {
|
||||
f.UpdateNginxConfigMapData("reuse-port", "true")
|
||||
|
||||
f.WaitForNginxConfiguration(func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf(`reuseport`))
|
||||
return strings.Contains(server, "reuseport")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue