Skip to content

Commit

Permalink
tmp: additional debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Feb 15, 2022
1 parent cf642b8 commit 8b0ecbb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/e2e/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package e2e
import (
"context"
"crypto/tls"
"os"
"os/exec"
"testing"
"time"

Expand All @@ -14,6 +16,7 @@ import (
"github.com/kong/kubernetes-testing-framework/pkg/clusters/addons/loadimage"
"github.com/kong/kubernetes-testing-framework/pkg/clusters/addons/metallb"
"github.com/kong/kubernetes-testing-framework/pkg/environments"
"github.com/kong/kubernetes-testing-framework/pkg/utils/kubernetes/generators"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -203,13 +206,31 @@ func TestWebhookUpdate(t *testing.T) {
_, err = env.Cluster().Client().CoreV1().Secrets("kong").Update(ctx, secondCertificate, metav1.UpdateOptions{})
assert.NoError(t, err)

t.Log("dumping kubeconfig to tempfile")
kubeconfig, err := generators.NewKubeConfigForRestConfig(env.Name(), env.Cluster().Config())
require.NoError(t, err)
kubeconfigFile, err := os.CreateTemp(os.TempDir(), "manifest-tests-kubeconfig-")
require.NoError(t, err)
defer os.Remove(kubeconfigFile.Name())
defer kubeconfigFile.Close()
written, err := kubeconfigFile.Write(kubeconfig)
require.NoError(t, err)
require.Equal(t, len(kubeconfig), written)
kubeconfigFilename := kubeconfigFile.Name()

t.Log("checking second certificate")
require.Eventually(t, func() bool {
conn, err := tls.Dial("tcp", admissionAddress+":443",
&tls.Config{MinVersion: tls.VersionTLS13, InsecureSkipVerify: true}) // nolint:gosec
if err != nil {
t.Logf("could not connect: %s", err)
return false
}
t.Logf("observed certificate: %s", conn.ConnectionState().PeerCertificates[0].Subject.CommonName)
cmd := exec.Command("kubectl", "--kubeconfig", kubeconfigFilename, "exec", "-it", "-n", "kong",
"deploy/ingress-kong", "-c", "ingress-controller", "--", "ls", "-l", "/admission-webhook")
out, err := cmd.Output()
t.Logf("file status %s err %s", out, err)
return conn.ConnectionState().PeerCertificates[0].Subject.CommonName == "second.example"
}, time.Minute*8, time.Second)
}
Expand Down

0 comments on commit 8b0ecbb

Please sign in to comment.