Skip to content

Test webhooks with and without watch cache enabled #79659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions test/integration/apiserver/admissionwebhook/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,18 @@ func (h *holder) verifyOptions(options runtime.Object) error {
return nil
}

// TestWebhookAdmission tests communication between API server and webhook process.
func TestWebhookAdmission(t *testing.T) {
// TestWebhookAdmissionWithWatchCache tests communication between API server and webhook process.
func TestWebhookAdmissionWithWatchCache(t *testing.T) {
testWebhookAdmission(t, true)
}

// TestWebhookAdmissionWithoutWatchCache tests communication between API server and webhook process.
func TestWebhookAdmissionWithoutWatchCache(t *testing.T) {
testWebhookAdmission(t, false)
}

// testWebhookAdmission tests communication between API server and webhook process.
func testWebhookAdmission(t *testing.T, watchCache bool) {
// holder communicates expectations to webhooks, and results from webhooks
holder := &holder{
t: t,
Expand Down Expand Up @@ -428,6 +438,7 @@ func TestWebhookAdmission(t *testing.T) {
// start API server
etcdConfig := framework.SharedEtcd()
server := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{
fmt.Sprintf("--watch-cache=%v", watchCache),
// turn off admission plugins that add finalizers
"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection",
// force enable all resources so we can check storage.
Expand Down
15 changes: 13 additions & 2 deletions test/integration/apiserver/admissionwebhook/reinvocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ const (
testReinvocationClientUsername = "webhook-reinvocation-integration-client"
)

// TestWebhookReinvocationPolicy ensures that the admission webhook reinvocation policy is applied correctly.
func TestWebhookReinvocationPolicy(t *testing.T) {
// TestWebhookReinvocationPolicyWithWatchCache ensures that the admission webhook reinvocation policy is applied correctly with the watch cache enabled.
func TestWebhookReinvocationPolicyWithWatchCache(t *testing.T) {
testWebhookReinvocationPolicy(t, true)
}

// TestWebhookReinvocationPolicyWithoutWatchCache ensures that the admission webhook reinvocation policy is applied correctly without the watch cache enabled.
func TestWebhookReinvocationPolicyWithoutWatchCache(t *testing.T) {
testWebhookReinvocationPolicy(t, false)
}

// testWebhookReinvocationPolicy ensures that the admission webhook reinvocation policy is applied correctly.
func testWebhookReinvocationPolicy(t *testing.T, watchCache bool) {
reinvokeNever := registrationv1beta1.NeverReinvocationPolicy
reinvokeIfNeeded := registrationv1beta1.IfNeededReinvocationPolicy

Expand Down Expand Up @@ -175,6 +185,7 @@ func TestWebhookReinvocationPolicy(t *testing.T) {

s := kubeapiservertesting.StartTestServerOrDie(t, kubeapiservertesting.NewDefaultTestServerOptions(), []string{
"--disable-admission-plugins=ServiceAccount",
fmt.Sprintf("--watch-cache=%v", watchCache),
}, framework.SharedEtcd())
defer s.TearDownFn()

Expand Down