Remove library.AssertNoRestartsDuringTest and make that assertion implicit in library.IntegrationEnv.
This means we (hopefully) can't forget to include these assertions in any integration test. Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
d85135c12e
commit
5a43a5d53a
@ -35,8 +35,6 @@ import (
|
||||
func TestCLIGetKubeconfigStaticToken(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
|
||||
// Create a test webhook configuration to use with the CLI.
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 4*time.Minute)
|
||||
defer cancelFunc()
|
||||
|
@ -23,8 +23,6 @@ func TestAPIServingCertificateAutoCreationAndRotation(t *testing.T) {
|
||||
env := library.IntegrationEnv(t)
|
||||
defaultServingCertResourceName := env.ConciergeAppName + "-api-tls-serving-certificate"
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
forceRotation func(context.Context, kubernetes.Interface, string) error
|
||||
|
@ -57,8 +57,6 @@ var maskKey = func(s string) string { return strings.ReplaceAll(s, "TESTING KEY"
|
||||
func TestClient(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
@ -23,8 +23,6 @@ func TestCredentialIssuer(t *testing.T) {
|
||||
client := library.NewConciergeClientset(t)
|
||||
aggregatedClientset := library.NewAggregatedClientset(t)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
@ -23,9 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUnsuccessfulCredentialRequest(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.AnonymousAuthenticationSupported)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
_ = library.IntegrationEnv(t).WithCapability(library.AnonymousAuthenticationSupported)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@ -44,8 +42,6 @@ func TestUnsuccessfulCredentialRequest(t *testing.T) {
|
||||
func TestSuccessfulCredentialRequest(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
@ -131,9 +127,7 @@ func TestSuccessfulCredentialRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFailedCredentialRequestWhenTheRequestIsValidButTheTokenDoesNotAuthenticateTheUser(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
_ = library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
// Create a testWebhook so we have a legitimate authenticator to pass to the
|
||||
// TokenCredentialRequest API.
|
||||
@ -154,9 +148,7 @@ func TestFailedCredentialRequestWhenTheRequestIsValidButTheTokenDoesNotAuthentic
|
||||
}
|
||||
|
||||
func TestCredentialRequest_ShouldFailWhenRequestDoesNotIncludeToken(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
_ = library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
// Create a testWebhook so we have a legitimate authenticator to pass to the
|
||||
// TokenCredentialRequest API.
|
||||
@ -184,9 +176,7 @@ func TestCredentialRequest_ShouldFailWhenRequestDoesNotIncludeToken(t *testing.T
|
||||
}
|
||||
|
||||
func TestCredentialRequest_OtherwiseValidRequestWithRealTokenShouldFailWhenTheClusterIsNotCapable(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithoutCapability(library.ClusterSigningKeyIsAvailable).WithCapability(library.AnonymousAuthenticationSupported)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
_ = library.IntegrationEnv(t).WithoutCapability(library.ClusterSigningKeyIsAvailable).WithCapability(library.AnonymousAuthenticationSupported)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
|
@ -28,8 +28,6 @@ const (
|
||||
func TestKubeCertAgent(t *testing.T) {
|
||||
env := library.IntegrationEnv(t).WithCapability(library.ClusterSigningKeyIsAvailable)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
|
@ -46,9 +46,6 @@ func TestE2EFullIntegration(t *testing.T) {
|
||||
defer library.DumpLogs(t, env.SupervisorNamespace, "")
|
||||
defer library.DumpLogs(t, "dex", "app=proxy")
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.ConciergeNamespace, "")
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancelFunc()
|
||||
|
||||
|
@ -45,8 +45,6 @@ func TestSupervisorOIDCDiscovery(t *testing.T) {
|
||||
env := library.IntegrationEnv(t)
|
||||
client := library.NewSupervisorClientset(t)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ns := env.SupervisorNamespace
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
@ -152,8 +150,6 @@ func TestSupervisorTLSTerminationWithSNI(t *testing.T) {
|
||||
pinnipedClient := library.NewSupervisorClientset(t)
|
||||
kubeClient := library.NewKubernetesClientset(t)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ns := env.SupervisorNamespace
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
@ -225,8 +221,6 @@ func TestSupervisorTLSTerminationWithDefaultCerts(t *testing.T) {
|
||||
pinnipedClient := library.NewSupervisorClientset(t)
|
||||
kubeClient := library.NewKubernetesClientset(t)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ns := env.SupervisorNamespace
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
|
@ -29,8 +29,6 @@ func TestSupervisorHealthz(t *testing.T) {
|
||||
t.Skip("PINNIPED_TEST_SUPERVISOR_HTTP_ADDRESS not defined")
|
||||
}
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
|
@ -44,8 +44,6 @@ func TestSupervisorLogin(t *testing.T) {
|
||||
defer library.DumpLogs(t, env.SupervisorNamespace, "")
|
||||
defer library.DumpLogs(t, "dex", "app=proxy")
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
|
@ -24,8 +24,6 @@ func TestSupervisorSecrets(t *testing.T) {
|
||||
kubeClient := library.NewKubernetesClientset(t)
|
||||
supervisorClient := library.NewSupervisorClientset(t)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
|
@ -17,8 +17,6 @@ import (
|
||||
func TestSupervisorUpstreamOIDCDiscovery(t *testing.T) {
|
||||
env := library.IntegrationEnv(t)
|
||||
|
||||
library.AssertNoRestartsDuringTest(t, env.SupervisorNamespace, "")
|
||||
|
||||
t.Run("invalid missing secret and bad issuer", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
spec := v1alpha1.OIDCIdentityProviderSpec{
|
||||
|
@ -29,9 +29,9 @@ func RequireEventuallyWithoutError(
|
||||
require.NoError(t, wait.PollImmediate(tick, waitFor, f), msgAndArgs...)
|
||||
}
|
||||
|
||||
// NewRestartAssertion allows a caller to assert that there were no restarts for a Pod in the
|
||||
// assertNoRestartsDuringTest allows a caller to assert that there were no restarts for a Pod in the
|
||||
// provided namespace with the provided labelSelector during the lifetime of a test.
|
||||
func AssertNoRestartsDuringTest(t *testing.T, namespace, labelSelector string) {
|
||||
func assertNoRestartsDuringTest(t *testing.T, namespace, labelSelector string) {
|
||||
t.Helper()
|
||||
|
||||
previousRestartCounts := getRestartCounts(t, namespace, labelSelector)
|
||||
|
@ -97,6 +97,10 @@ func IntegrationEnv(t *testing.T) *TestEnv {
|
||||
|
||||
loadEnvVars(t, &result)
|
||||
|
||||
// In every integration test, assert that no pods in our namespaces restart during the test.
|
||||
assertNoRestartsDuringTest(t, result.ConciergeNamespace, "")
|
||||
assertNoRestartsDuringTest(t, result.SupervisorNamespace, "")
|
||||
|
||||
result.t = t
|
||||
return &result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user