Skip to content

Commit

Permalink
Fix configz test failures (#13478)
Browse files Browse the repository at this point in the history
* Fix configz test failures

* Dynamically assign port
  • Loading branch information
howardjohn authored and istio-testing committed Apr 22, 2019
1 parent 803bd24 commit a2c0067
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pkg/ctrlz/ctrlz.go
Expand Up @@ -195,7 +195,8 @@ func (s *Server) listen() {
// Close is not normally used by programs that expose ControlZ, it is primarily intended to be
// used by tests.
func (s *Server) Close() {
log.Info("Closing closing ControlZ")
log.Info("Closing ControlZ")

if s.listener != nil {
if err := s.listener.Close(); err != nil {
log.Warnf("Error closing ControlZ: %v", err)
Expand Down
8 changes: 6 additions & 2 deletions pkg/mcp/configz/client/configz_test.go
Expand Up @@ -77,10 +77,14 @@ func TestConfigZ(t *testing.T) {
defer cancel()

o := ctrlz.DefaultOptions()
cz, _ := ctrlz.Run(o, []fw.Topic{CreateTopic(cl)})
o.Port = 0
cz, err := ctrlz.Run(o, []fw.Topic{CreateTopic(cl)})
if err != nil {
t.Fatal(err)
}
defer cz.Close()

baseURL := fmt.Sprintf("http://%s:%d", o.Address, o.Port)
baseURL := fmt.Sprintf("http://%v", cz.Address())

// wait for client to make first watch request
for {
Expand Down
12 changes: 8 additions & 4 deletions pkg/mcp/configz/server/configz_test.go
Expand Up @@ -22,11 +22,11 @@ import (
"testing"
"time"

"github.com/gogo/protobuf/types"

"istio.io/istio/pkg/mcp/source"
"istio.io/istio/pkg/mcp/testing/groups"

"github.com/gogo/protobuf/types"

"istio.io/istio/pkg/ctrlz"
"istio.io/istio/pkg/ctrlz/fw"
"istio.io/istio/pkg/mcp/snapshot"
Expand All @@ -52,10 +52,14 @@ func TestConfigZ(t *testing.T) {
s.Cache.SetSnapshot(groups.Default, b.Build())

o := ctrlz.DefaultOptions()
cz, _ := ctrlz.Run(o, []fw.Topic{CreateTopic(s.Cache)})
o.Port = 0
cz, err := ctrlz.Run(o, []fw.Topic{CreateTopic(s.Cache)})
if err != nil {
t.Fatal(err)
}
defer cz.Close()

baseURL := fmt.Sprintf("http://%s:%d", o.Address, o.Port)
baseURL := fmt.Sprintf("http://%v", cz.Address())

t.Run("configj with 1 request", func(tt *testing.T) { testConfigJWithOneRequest(tt, baseURL) })
}
Expand Down

0 comments on commit a2c0067

Please sign in to comment.