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

flush servers #104

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version = 1

test_patterns = [
'*_test.go'
]

exclude_patterns = [

]

[[analyzers]]
name = 'go'
enabled = true


[analyzers.meta]
import_path = 'github.com/samuel/go-zookeeper/zk'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.vscode/
.DS_Store
profile.cov
zookeeper
zookeeper-*/
zookeeper-*.tar.gz
34 changes: 21 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
arch:
- amd64
- ppc64le
language: go
go:
- 1.9
- "1.11"
- "1.x"
- tip

go_import_path: github.com/samuel/go-zookeeper

jdk:
- oraclejdk9
Expand All @@ -12,22 +19,23 @@ branches:
- master

before_install:
- wget http://apache.cs.utah.edu/zookeeper/zookeeper-${zk_version}/zookeeper-${zk_version}.tar.gz
- tar -zxvf zookeeper*tar.gz && zip -d zookeeper-${zk_version}/contrib/fatjar/zookeeper-${zk_version}-fatjar.jar 'META-INF/*.SF' 'META-INF/*.DSA'
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
- make setup ZK_VERSION=${zk_version}

before_script:
- make lint

script:
- jdk_switcher use oraclejdk9
- go build ./...
- go fmt ./...
- go vet ./...
- go test -i -race ./...
- go test -race -covermode atomic -coverprofile=profile.cov ./zk
- goveralls -coverprofile=profile.cov -service=travis-ci
- jdk_switcher use oraclejdk9 || true
- make

matrix:
allow_failures:
- go: tip
fast_finish: true

env:
global:
secure: Coha3DDcXmsekrHCZlKvRAc+pMBaQU1QS/3++3YCCUXVDBWgVsC1ZIc9df4RLdZ/ncGd86eoRq/S+zyn1XbnqK5+ePqwJoUnJ59BE8ZyHLWI9ajVn3fND1MTduu/ksGsS79+IYbdVI5wgjSgjD3Ktp6Y5uPl+BPosjYBGdNcHS4=
matrix:
- zk_version=3.4.10
- zk_version=3.5.4-beta
- zk_version=3.4.12
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# make file to hold the logic of build and test setup
ZK_VERSION ?= 3.4.12

ZK = zookeeper-$(ZK_VERSION)
ZK_URL = "https://archive.apache.org/dist/zookeeper/$(ZK)/$(ZK).tar.gz"

PACKAGES := $(shell go list ./... | grep -v examples)

.DEFAULT_GOAL := test

$(ZK):
wget $(ZK_URL)
tar -zxf $(ZK).tar.gz
# 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

.PHONY: install-covertools
install-covertools:
go get github.com/mattn/goveralls
go get golang.org/x/tools/cmd/cover

.PHONY: setup
setup: $(ZK) install-covertools

.PHONY: lint
lint:
go fmt ./...
go vet ./...

.PHONY: build
build:
go build ./...

.PHONY: test
test: build
go test -timeout 500s -v -race -covermode atomic -coverprofile=profile.cov $(PACKAGES)
# ignore if we fail to publish coverage
-goveralls -coverprofile=profile.cov -service=travis-ci
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ License
-------

3-clause BSD. See LICENSE file.

This Repository is No Longer Maintained
=======================================

Please use https://github.com/go-zookeeper/zk for an actively maintained fork.
19 changes: 10 additions & 9 deletions zk/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ func (lw logWriter) Write(b []byte) (int, error) {
}

func TestBasicCluster(t *testing.T) {
ts, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "})
ts, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
}
defer ts.Stop()
zk1, err := ts.Connect(0)
zk1, _, err := ts.Connect(0)
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
}
defer zk1.Close()
zk2, err := ts.Connect(1)
zk2, _, err := ts.Connect(1)
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
}
Expand All @@ -38,6 +38,7 @@ func TestBasicCluster(t *testing.T) {
if _, err := zk1.Create("/gozk-test", []byte("foo-cluster"), 0, WorldACL(PermAll)); err != nil {
t.Fatalf("Create failed on node 1: %+v", err)
}

if by, _, err := zk2.Get("/gozk-test"); err != nil {
t.Fatalf("Get failed on node 2: %+v", err)
} else if string(by) != "foo-cluster" {
Expand All @@ -47,7 +48,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) {
tc, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "})
tc, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -89,7 +90,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) {
tc, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "})
tc, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -149,7 +150,7 @@ func TestNoQuorum(t *testing.T) {
DefaultLogger.Printf(" Retrying no luck...")
var firstDisconnect *Event
begin := time.Now()
for time.Now().Sub(begin) < 6*time.Second {
for time.Since(begin) < 6*time.Second {
disconnectedEvent := sl.NewWatcher(sessionStateMatcher(StateDisconnected)).Wait(4 * time.Second)
if disconnectedEvent == nil {
t.Fatalf("Disconnected event expected")
Expand Down Expand Up @@ -185,12 +186,12 @@ func TestNoQuorum(t *testing.T) {
}

func TestWaitForClose(t *testing.T) {
ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "})
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
if err != nil {
t.Fatal(err)
}
defer ts.Stop()
zk, err := ts.Connect(0)
zk, _, err := ts.Connect(0)
if err != nil {
t.Fatalf("Connect returned error: %+v", err)
}
Expand Down Expand Up @@ -221,7 +222,7 @@ CONNECTED:
}

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