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

Merge linkedin/go-zk changes upstream #122

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jobs:
name: integration_test
strategy:
matrix:
zk-version: [3.5.8, 3.6.1]
zk-version: [3.5.8, 3.6.3]
go-version: ['oldstable', 'stable']
runs-on: ubuntu-latest
steps:
- name: Go ${{ matrix.go }} setup
- name: Go ${{ matrix.go-version }} setup
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ matrix.go-version }}

- name: Setup Java 14
uses: actions/setup-java@v3
Expand All @@ -22,7 +22,7 @@ jobs:
java-version: 14

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Test code
run: make test ZK_VERSION=${{ matrix.zk-version }}
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@

name: lint
on: [pull_request]
on: [push, pull_request]

jobs:
lint:
name: lint
strategy:
matrix:
go-version: ["1.21"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Lint code
uses: reviewdog/action-golangci-lint@v1
uses: actions/checkout@v4

- name: Install go
uses: actions/setup-go@v4
with:
github_token: ${{ secrets.github_token }}
go-version: ${{ matrix.go-version }}

- name: Lint code
uses: golangci/golangci-lint-action@v3
6 changes: 3 additions & 3 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
go-version: ['oldstable', 'stable']
runs-on: ubuntu-latest
steps:
- name: Go ${{ matrix.go }} setup
- name: Go ${{ matrix.go-version }} setup
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3

- name: Run unittest ${{ matrix.go }}
run: make unittest
run: make unittest
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# make file to hold the logic of build and test setup
ZK_VERSION ?= 3.5.6
export ZK_VERSION ?= 3.6.3

# Apache changed the name of the archive in version 3.5.x and seperated out
# src and binary packages
Expand All @@ -20,10 +20,12 @@ $(ZK):
tar -zxf $(ZK).tar.gz
rm $(ZK).tar.gz

.PHONY: zookeeper
zookeeper: $(ZK)
# we link to a standard directory path so then the tests dont need to find based on version
# in the test code. this allows backward compatable testing.
ln -s $(ZK) zookeeper
rm -f $@
ln -s $(ZK) $@

.PHONY: setup
setup: zookeeper
Expand Down
11 changes: 6 additions & 5 deletions cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zk

import (
"log/slog"
"sync"
"testing"
"time"
Expand All @@ -21,7 +22,7 @@
if err != nil {
t.Fatal(err)
}
defer ts.Stop()

Check failure on line 25 in cluster_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value of `ts.Stop` is not checked (errcheck)
zk1, _, err := ts.Connect(0)
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
Expand Down Expand Up @@ -56,7 +57,7 @@
if err != nil {
t.Fatal(err)
}
defer tc.Stop()

Check failure on line 60 in cluster_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value of `tc.Stop` is not checked (errcheck)
zk, evCh, err := tc.ConnectAll()
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
Expand Down Expand Up @@ -98,7 +99,7 @@
if err != nil {
t.Fatal(err)
}
defer tc.Stop()

Check failure on line 102 in cluster_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value of `tc.Stop` is not checked (errcheck)
zk, evCh, err := tc.ConnectAllTimeout(4 * time.Second)
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
Expand All @@ -112,10 +113,10 @@
t.Fatalf("Failed to connect and get session")
}
initialSessionID := zk.sessionID
DefaultLogger.Printf(" Session established: id=%d, timeout=%d", zk.sessionID, zk.sessionTimeoutMs)
t.Logf("Session established: id=%d, timeout=%d", zk.sessionID, zk.sessionTimeout)

// Kill the ZooKeeper leader and wait for the session to reconnect.
DefaultLogger.Printf(" Kill the leader")
t.Logf("Kill the leader")
disconnectWatcher1 := sl.NewWatcher(sessionStateMatcher(StateDisconnected))
hasSessionWatcher2 := sl.NewWatcher(sessionStateMatcher(StateHasSession))
tc.StopServer(hasSessionEvent1.Server)
Expand All @@ -135,7 +136,7 @@
}

// Kill the ZooKeeper leader leaving the cluster without quorum.
DefaultLogger.Printf(" Kill the leader")
t.Logf("Kill the leader")
disconnectWatcher2 := sl.NewWatcher(sessionStateMatcher(StateDisconnected))
tc.StopServer(hasSessionEvent2.Server)

Expand All @@ -151,7 +152,7 @@
// Make sure that we keep retrying connecting to the only remaining
// ZooKeeper server, but the attempts are being dropped because there is
// no quorum.
DefaultLogger.Printf(" Retrying no luck...")
t.Logf("Retrying no luck...")
var firstDisconnect *Event
begin := time.Now()
for time.Now().Sub(begin) < 6*time.Second {
Expand Down Expand Up @@ -194,7 +195,7 @@
if err != nil {
t.Fatal(err)
}
defer ts.Stop()

Check failure on line 198 in cluster_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value of `ts.Stop` is not checked (errcheck)
zk, _, err := ts.Connect(0)
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
Expand Down Expand Up @@ -230,7 +231,7 @@
if err != nil {
t.Fatal(err)
}
defer ts.Stop()

Check failure on line 234 in cluster_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value of `ts.Stop` is not checked (errcheck)
zk, _, err := ts.ConnectAll()
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
Expand Down Expand Up @@ -269,7 +270,7 @@
sw.matchCh <- event
}
}
DefaultLogger.Printf(" event received: %v\n", event)
slog.Info("event received", "event", event)
el.events = append(el.events, event)
el.lock.Unlock()
}
Expand Down
Loading
Loading