Skip to content

Commit

Permalink
Merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PapaCharlie committed Feb 5, 2024
1 parent 54c3d79 commit 7655110
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ lint:
build:
go build ./...

.PHONY: unittest
unittest:
go test -timeout 500s -v -race -covermode atomic -skip=Integration ./...

.PHONY: test
test: build zookeeper
go test -timeout 500s -v -race -covermode atomic -coverprofile=profile.cov $(PACKAGES)
Expand Down
10 changes: 5 additions & 5 deletions cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (lw logWriter) Write(b []byte) (int, error) {
return len(b), nil
}

func TestBasicCluster(t *testing.T) {
func TestIntegration_BasicCluster(t *testing.T) {
ts, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestBasicCluster(t *testing.T) {
}

// If the current leader dies, then the session is reestablished with the new one.
func TestClientClusterFailover(t *testing.T) {
func TestIntegration_ClientClusterFailover(t *testing.T) {
tc, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestClientClusterFailover(t *testing.T) {

// If a ZooKeeper cluster looses quorum then a session is reconnected as soon
// as the quorum is restored.
func TestNoQuorum(t *testing.T) {
func TestIntegration_NoQuorum(t *testing.T) {
tc, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestNoQuorum(t *testing.T) {
}
}

func TestWaitForClose(t *testing.T) {
func TestIntegration_WaitForClose(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -226,7 +226,7 @@ CONNECTED:
}
}

func TestBadSession(t *testing.T) {
func TestIntegration_BadSession(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
)

func TestRecurringReAuthHang(t *testing.T) {
func TestIntegration_RecurringReAuthHang(t *testing.T) {
zkC, err := StartTestCluster(t, 3, ioutil.Discard, ioutil.Discard)
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions dnshostprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func localhostLookupHost(host string) ([]string, error) {

// TestDNSHostProviderCreate is just like TestCreate, but with an
// overridden HostProvider that ignores the provided hostname.
func TestDNSHostProviderCreate(t *testing.T) {
func TestIntegration_DNSHostProviderCreate(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -96,7 +96,7 @@ var _ HostProvider = &localHostPortsFacade{}
// restarts. It wraps the DNSHostProvider in a lightweight facade that
// remaps addresses to localhost:$PORT combinations corresponding to
// the test ZooKeeper instances.
func TestDNSHostProviderReconnect(t *testing.T) {
func TestIntegration_DNSHostProviderReconnect(t *testing.T) {
ts, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

func TestLock(t *testing.T) {
func TestIntegration_Lock(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestLock(t *testing.T) {

// This tests creating a lock with a path that's more than 1 node deep (e.g. "/test-multi-level/lock"),
// when a part of that path already exists (i.e. "/test-multi-level" node already exists).
func TestMultiLevelLock(t *testing.T) {
func TestIntegration_MultiLevelLock(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 2 additions & 0 deletions server_help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func WithTestCluster(t *testing.T, testTimeout time.Duration, f func(ts *TestClu
// testing. This should be used on CI systems and local only when needed whereas unit tests should remain
// fast and not rely on external dependencies.
func StartTestCluster(t *testing.T, size int, stdout, stderr io.Writer) (*TestCluster, error) {
t.Helper()

if testing.Short() {
t.Skip("ZK cluster tests skipped in short case.")
}
Expand Down
2 changes: 1 addition & 1 deletion server_java_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (srv *server) Start() error {
srv.cmd = exec.CommandContext(ctx, srv.cmdString, srv.cmdArgs...)
srv.cmd.Stdout = srv.stdout
srv.cmd.Stderr = srv.stderr
srv.cmd.Env = srv.cmdEnv
srv.cmd.Env = append(os.Environ(), srv.cmdEnv...)

return srv.cmd.Start()
}
Expand Down
47 changes: 24 additions & 23 deletions zk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"
)

func TestStateChanges(t *testing.T) {
func TestIntegration_StateChanges(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestStateChanges(t *testing.T) {
verifyEventOrder(eventChan, []State{StateDisconnected}, "event channel")
}

func TestCreate(t *testing.T) {
func TestIntegration_Create(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestCreate(t *testing.T) {
}
}

func TestCreateTTL(t *testing.T) {
func TestIntegration_CreateTTL(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestCreateTTL(t *testing.T) {
}
}

func TestCreateContainer(t *testing.T) {
func TestIntegration_CreateContainer(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestCreateContainer(t *testing.T) {
}
}

func TestIncrementalReconfig(t *testing.T) {
func TestIntegration_IncrementalReconfig(t *testing.T) {
RequireMinimumZkVersion(t, "3.5")

ts, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
Expand Down Expand Up @@ -275,7 +275,7 @@ func TestIncrementalReconfig(t *testing.T) {
}
}

func TestReconfig(t *testing.T) {
func TestIntegration_Reconfig(t *testing.T) {
RequireMinimumZkVersion(t, "3.5")

// This test enures we can do an non-incremental reconfig
Expand Down Expand Up @@ -320,7 +320,7 @@ func TestReconfig(t *testing.T) {
requireNoErrorf(t, err, "failed to reconfig cluster")
}

func TestOpsAfterCloseDontDeadlock(t *testing.T) {
func TestIntegration_OpsAfterCloseDontDeadlock(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestOpsAfterCloseDontDeadlock(t *testing.T) {
}
}

func TestMulti(t *testing.T) {
func TestIntegration_Multi(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -388,7 +388,7 @@ func TestMulti(t *testing.T) {
}
}

func TestMultiRead(t *testing.T) {
func TestIntegration_MultiRead(t *testing.T) {
RequireMinimumZkVersion(t, "3.6")
WithTestCluster(t, 10*time.Second, func(ts *TestCluster, zk *Conn) {
nodeChildren := map[string][]string{}
Expand Down Expand Up @@ -478,7 +478,7 @@ func TestMultiRead(t *testing.T) {
})
}

func TestGetDataAndChildren(t *testing.T) {
func TestIntegration_GetDataAndChildren(t *testing.T) {
RequireMinimumZkVersion(t, "3.6")
WithTestCluster(t, 10*time.Second, func(ts *TestCluster, zk *Conn) {

Expand Down Expand Up @@ -516,7 +516,7 @@ func TestGetDataAndChildren(t *testing.T) {
})
}

func TestIfAuthdataSurvivesReconnect(t *testing.T) {
func TestIntegration_IfAuthdataSurvivesReconnect(t *testing.T) {
// This test case ensures authentication data is being resubmited after
// reconnect.
testNode := "/auth-testnode"
Expand Down Expand Up @@ -568,8 +568,9 @@ func TestIfAuthdataSurvivesReconnect(t *testing.T) {
}
}

func TestPersistentWatchOnReconnect(t *testing.T) {
func TestIntegration_PersistentWatchOnReconnect(t *testing.T) {
RequireMinimumZkVersion(t, "3.6")

WithTestCluster(t, 10*time.Second, func(ts *TestCluster, zk *Conn) {
zk.reconnectLatch = make(chan struct{})

Expand Down Expand Up @@ -647,7 +648,7 @@ func waitForEvent(t *testing.T, timeout time.Duration, ch EventQueue, expectedTy
return e
}

func TestPersistentWatchOnClose(t *testing.T) {
func TestIntegration_PersistentWatchOnClose(t *testing.T) {
RequireMinimumZkVersion(t, "3.6")
WithTestCluster(t, 10*time.Second, func(_ *TestCluster, zk *Conn) {
ch, err := zk.AddPersistentWatch("/", AddWatchModePersistent)
Expand All @@ -659,7 +660,7 @@ func TestPersistentWatchOnClose(t *testing.T) {
})
}

func TestPersistentWatchGetsPinged(t *testing.T) {
func TestIntegration_PersistentWatchGetsPinged(t *testing.T) {
RequireMinimumZkVersion(t, "3.6")
WithTestCluster(t, 60*time.Second, func(_ *TestCluster, zk *Conn) {
ch, err := zk.AddPersistentWatch("/", AddWatchModePersistent)
Expand All @@ -672,7 +673,7 @@ func TestPersistentWatchGetsPinged(t *testing.T) {
})
}

func TestMultiFailures(t *testing.T) {
func TestIntegration_MultiFailures(t *testing.T) {
// This test case ensures that we return the errors associated with each
// opeThis in the event a call to Multi() fails.
const firstPath = "/gozk-test-first"
Expand Down Expand Up @@ -720,7 +721,7 @@ func TestMultiFailures(t *testing.T) {
}
}

func TestGetSetACL(t *testing.T) {
func TestIntegration_GetSetACL(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -774,7 +775,7 @@ func TestGetSetACL(t *testing.T) {
}
}

func TestAuth(t *testing.T) {
func TestIntegration_Auth(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -825,7 +826,7 @@ func TestAuth(t *testing.T) {
}

// Tests that we correctly handle a response larger than the default buffer size
func TestChildren(t *testing.T) {
func TestIntegration_Children(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -884,7 +885,7 @@ func TestChildren(t *testing.T) {
}
}

func TestChildWatch(t *testing.T) {
func TestIntegration_ChildWatch(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -955,7 +956,7 @@ func TestChildWatch(t *testing.T) {
}
}

func TestSetWatchers(t *testing.T) {
func TestIntegration_SetWatchers(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1104,7 +1105,7 @@ func TestSetWatchers(t *testing.T) {
}
}

func TestExpiringWatch(t *testing.T) {
func TestIntegration_ExpiringWatch(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1180,7 +1181,7 @@ func TestIdempotentClose(t *testing.T) {
zk.Close()
}

func TestSlowServer(t *testing.T) {
func TestIntegration_SlowServer(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1239,7 +1240,7 @@ func TestSlowServer(t *testing.T) {
}
}

func TestMaxBufferSize(t *testing.T) {
func TestIntegration_MaxBufferSize(t *testing.T) {
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 7655110

Please sign in to comment.