Skip to content

Commit

Permalink
feedback from easwar:
Browse files Browse the repository at this point in the history
- close credentials provider for each authority
- Fatal tests where possible.
  • Loading branch information
atollena committed Dec 21, 2023
1 parent 8f3472e commit e694f4c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions xds/internal/xdsclient/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ func (a *authority) close() {
a.resourcesMu.Lock()
a.closed = true
a.resourcesMu.Unlock()

for _, cleanup := range a.serverCfg.Cleanups {
cleanup()
}
}

func (a *authority) watchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) func() {
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/xdsclient/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,11 +1056,11 @@ func TestCredsBuilders(t *testing.T) {

func TestTlsCredsBuilder(t *testing.T) {
tls := &tlsCredsBuilder{}
if _, stop, err := tls.Build(json.RawMessage(`{}`)); err != nil {
t.Errorf("tls.Build() failed with error %s when expected to succeed", err)
} else {
stop()
_, stop, err := tls.Build(json.RawMessage(`{}`))
if err != nil {
t.Fatalf("tls.Build() failed with error %s when expected to succeed", err)
}
stop()
if _, stop, err := tls.Build(json.RawMessage(`{"ca_certificate_file":"/ca_certificates.pem","refresh_interval": "asdf"}`)); err == nil {
t.Errorf("tls.Build() succeeded with an invalid refresh interval, when expected to fail")
stop()
Expand Down
3 changes: 0 additions & 3 deletions xds/internal/xdsclient/clientimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,5 @@ func (c *clientImpl) close() {
c.authorityMu.Unlock()
c.serializerClose()

for _, f := range c.config.XDSServer.Cleanups {
f()
}
c.logger.Infof("Shutdown")
}
4 changes: 3 additions & 1 deletion xds/internal/xdsclient/tlscreds/bundle_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ func (s) TestInvalidTlsBuilder(t *testing.T) {
msg := json.RawMessage(test.jd)
if _, stop, err := tlscreds.NewBundle(msg); err == nil || !strings.HasPrefix(err.Error(), test.wantErrPrefix) {
t.Errorf("NewBundle(%s): got error %s, want an error with prefix %s", msg, err, test.wantErrPrefix)
stop()
if err == nil {
stop()
}
}
})
}
Expand Down

0 comments on commit e694f4c

Please sign in to comment.