Refactor e2e tests to use the service ClusterIP
This commit is contained in:
parent
f04361cc06
commit
5e249d3366
80 changed files with 777 additions and 706 deletions
|
|
@ -23,13 +23,12 @@ import (
|
|||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/tools/clientcmd/api"
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
|
|
@ -37,10 +36,10 @@ import (
|
|||
|
||||
const (
|
||||
// Poll how often to poll for conditions
|
||||
Poll = 2 * time.Second
|
||||
Poll = 3 * time.Second
|
||||
|
||||
// DefaultTimeout time to wait for operations to complete
|
||||
DefaultTimeout = 5 * time.Minute
|
||||
DefaultTimeout = 3 * time.Minute
|
||||
)
|
||||
|
||||
func nowStamp() string {
|
||||
|
|
@ -87,15 +86,6 @@ func RestclientConfig(config, context string) (*api.Config, error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// LoadConfig deserializes the contents of a kubeconfig file into a REST configuration.
|
||||
func LoadConfig(config, context string) (*rest.Config, error) {
|
||||
c, err := RestclientConfig(config, context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{}).ClientConfig()
|
||||
}
|
||||
|
||||
// RunID unique identifier of the e2e run
|
||||
var RunID = uuid.NewUUID()
|
||||
|
||||
|
|
@ -109,8 +99,9 @@ func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error
|
|||
}
|
||||
// Be robust about making the namespace creation call.
|
||||
var got *v1.Namespace
|
||||
err := wait.PollImmediate(Poll, DefaultTimeout, func() (bool, error) {
|
||||
var err error
|
||||
var err error
|
||||
|
||||
err = wait.PollImmediate(Poll, DefaultTimeout, func() (bool, error) {
|
||||
got, err = c.CoreV1().Namespaces().Create(ns)
|
||||
if err != nil {
|
||||
Logf("Unexpected error while creating namespace: %v", err)
|
||||
|
|
@ -200,7 +191,7 @@ func secretInNamespace(c kubernetes.Interface, namespace, name string) wait.Cond
|
|||
return func() (bool, error) {
|
||||
s, err := c.CoreV1().Secrets(namespace).Get(name, metav1.GetOptions{})
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
@ -268,7 +259,7 @@ func ingressInNamespace(c kubernetes.Interface, namespace, name string) wait.Con
|
|||
return func() (bool, error) {
|
||||
ing, err := c.ExtensionsV1beta1().Ingresses(namespace).Get(name, metav1.GetOptions{})
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
@ -285,7 +276,7 @@ func podRunning(c kubernetes.Interface, podName, namespace string) wait.Conditio
|
|||
return func() (bool, error) {
|
||||
pod, err := c.CoreV1().Pods(namespace).Get(podName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
return false, nil
|
||||
}
|
||||
switch pod.Status.Phase {
|
||||
case v1.PodRunning:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue