|
|
|
@ -159,8 +159,10 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
|
|
|
|
|
t.Fatalf("failed waititing for ingress-nginx-controller : %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createIngress := func() error {
|
|
|
|
|
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ing.yaml")))
|
|
|
|
|
// create networking.k8s.io/v1beta1 ingress
|
|
|
|
|
createv1betaIngress := func() error {
|
|
|
|
|
// apply networking.k8s.io/v1beta1 ingress
|
|
|
|
|
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ingv1beta.yaml")))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -170,7 +172,8 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := retry.Expo(createIngress, 1*time.Second, Seconds(90)); err != nil {
|
|
|
|
|
// create networking.k8s.io/v1beta1 ingress
|
|
|
|
|
if err := retry.Expo(createv1betaIngress, 1*time.Second, Seconds(90)); err != nil {
|
|
|
|
|
t.Errorf("failed to create ingress: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -188,7 +191,8 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
|
|
|
|
|
|
|
|
|
|
want := "Welcome to nginx!"
|
|
|
|
|
addr := "http://127.0.0.1/"
|
|
|
|
|
checkIngress := func() error {
|
|
|
|
|
// check if the ingress can route nginx app with networking.k8s.io/v1beta1 ingress
|
|
|
|
|
checkv1betaIngress := func() error {
|
|
|
|
|
var rr *RunResult
|
|
|
|
|
var err error
|
|
|
|
|
if NoneDriver() { // just run curl directly on the none driver
|
|
|
|
@ -215,7 +219,59 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := retry.Expo(checkIngress, 500*time.Millisecond, Seconds(90)); err != nil {
|
|
|
|
|
// check if the ingress can route nginx app with networking.k8s.io/v1beta1 ingress
|
|
|
|
|
if err := retry.Expo(checkv1betaIngress, 500*time.Millisecond, Seconds(90)); err != nil {
|
|
|
|
|
t.Errorf("failed to get expected response from %s within minikube: %v", addr, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create networking.k8s.io/v1 ingress
|
|
|
|
|
createv1Ingress := func() error {
|
|
|
|
|
// apply networking.k8s.io/v1beta1 ingress
|
|
|
|
|
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ingv1.yaml")))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if rr.Stderr.String() != "" {
|
|
|
|
|
t.Logf("%v: unexpected stderr: %s (may be temporary)", rr.Command(), rr.Stderr)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create networking.k8s.io/v1 ingress
|
|
|
|
|
if err := retry.Expo(createv1Ingress, 1*time.Second, Seconds(90)); err != nil {
|
|
|
|
|
t.Errorf("failed to create ingress: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check if the ingress can route nginx app with networking.k8s.io/v1 ingress
|
|
|
|
|
checkv1Ingress := func() error {
|
|
|
|
|
var rr *RunResult
|
|
|
|
|
var err error
|
|
|
|
|
if NoneDriver() { // just run curl directly on the none driver
|
|
|
|
|
rr, err = Run(t, exec.CommandContext(ctx, "curl", "-s", addr, "-H", "'Host: nginx.example.com'"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", fmt.Sprintf("curl -s %s -H 'Host: nginx.example.com'", addr)))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stderr := rr.Stderr.String()
|
|
|
|
|
if rr.Stderr.String() != "" {
|
|
|
|
|
t.Logf("debug: unexpected stderr for %v:\n%s", rr.Command(), stderr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stdout := rr.Stdout.String()
|
|
|
|
|
if !strings.Contains(stdout, want) {
|
|
|
|
|
return fmt.Errorf("%v stdout = %q, want %q", rr.Command(), stdout, want)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check if the ingress can route nginx app with networking.k8s.io/v1 ingress
|
|
|
|
|
if err := retry.Expo(checkv1Ingress, 500*time.Millisecond, Seconds(90)); err != nil {
|
|
|
|
|
t.Errorf("failed to get expected response from %s within minikube: %v", addr, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|