Skip to content
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

Fix attempt for test fail panics in xDS #16319

Merged
merged 3 commits into from
Feb 24, 2023
Merged
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
18 changes: 18 additions & 0 deletions agent/xds/delta_test.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"errors"
"strconv"
"strings"
"sync"
"sync/atomic"
"testing"
"time"
@@ -1058,6 +1059,15 @@ func TestServer_DeltaAggregatedResources_v3_ACLEnforcement(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var stopped bool
lock := &sync.RWMutex{}

defer func() {
lock.Lock()
stopped = true
lock.Unlock()
}()

// aclResolve may be called in a goroutine even after a
// testcase tt returns. Capture the variable as tc so the
// values don't swap in the next iteration.
@@ -1071,6 +1081,14 @@ func TestServer_DeltaAggregatedResources_v3_ACLEnforcement(t *testing.T) {
// No token and defaultDeny is denied
return acl.RootAuthorizer("deny"), nil
}

lock.RLock()
defer lock.RUnlock()

if stopped {
return acl.DenyAll().ToAllowAuthorizer(), nil
}

// Ensure the correct token was passed
require.Equal(t, tc.token, id)
// Parse the ACL and enforce it