Skip to content

Commit 54603c5

Browse files
authored
Merge branch 'master' into sasl
2 parents 1dd7138 + 6d30b8b commit 54603c5

28 files changed

+1104
-278
lines changed

.codecov.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ coverage:
22
status:
33
patch:
44
default:
5-
target: 75%
5+
target: 80%
66
project:
77
default:
8-
threshold: 1%
8+
threshold: 76%

.devcontainer/devcontainer.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/go
3+
{
4+
"name": "Go",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/go:0-1-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers/features/java:1": {
9+
}
10+
}
11+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.github/workflows/integration.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: integration_test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
integration_test:
12+
name: integration_test
13+
strategy:
14+
matrix:
15+
zk-version: [3.5.8, 3.6.1]
16+
go-version: ['oldstable', 'stable']
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Go ${{ matrix.go-version }} setup
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
- name: Setup Java 14
25+
uses: actions/setup-java@v3
26+
with:
27+
distribution: 'zulu'
28+
java-version: 14
29+
30+
- name: Checkout code
31+
uses: actions/checkout@v3
32+
33+
- name: Test code
34+
run: make test ZK_VERSION=${{ matrix.zk-version }}
35+
36+
- name: Upload code coverage
37+
# only upload one result from the matrix.
38+
if: ${{ strategy.job-index == 0 }}
39+
uses: codecov/codecov-action@v4
40+
with:
41+
token: ${{ secrets.CODECOV_TOKEN }} # required
42+
file: ./profile.cov

.github/workflows/lint.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
name: lint
33
on: [pull_request]
4+
45
jobs:
56
lint:
67
name: lint

.github/workflows/stale.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2+
#
3+
# You can adjust the behavior by modifying this file.
4+
# For more information, see:
5+
# https://github.com/actions/stale
6+
name: Mark stale issues and pull requests
7+
8+
on:
9+
schedule:
10+
- cron: '0 12 * * *'
11+
12+
jobs:
13+
stale:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
20+
steps:
21+
- uses: actions/stale@v9
22+
with:
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
stale-issue-label: 'no-issue-activity'
25+
stale-pr-label: 'no-pr-activity'
26+
days-before-stale: 180
27+
days-before-issue-stale: 730
28+
days-before-close: 30
29+
days-before-pr-close: -1
30+
stale-pr-message: 'Stale pull request detected at 180 days. Please update, comment, or rebase.'
31+
stale-issue-message: 'This issue is marked as stale. If you want to keep this issue open, please leave a comment, otherwise the issue will be closed due to inactivity.'
32+
close-issue-message: "This issue has been closed due to inactivity after being stale for 30 days."
33+
debug-only: true
34+
exempt-all-milestones: true
35+

.github/workflows/unittest.yaml

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
name: unittest
2-
on: [push, pull_request]
3-
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
410
jobs:
511
unittest:
612
name: unittest
713
strategy:
814
matrix:
9-
zk-version: [3.5.8, 3.6.1]
10-
go-version: [1.13.x, 1.14.x]
15+
go-version: ['oldstable', 'stable']
1116
runs-on: ubuntu-latest
1217
steps:
13-
- name: Setup Go
14-
uses: actions/setup-go@v1
18+
- name: Go ${{ matrix.go-version }} setup
19+
uses: actions/setup-go@v4
1520
with:
1621
go-version: ${{ matrix.go-version }}
1722

18-
- name: Setup Java
19-
uses: actions/setup-java@v1
20-
with:
21-
java-version: 14
22-
2323
- name: Checkout code
24-
uses: actions/checkout@v1
24+
uses: actions/checkout@v3
2525

26-
- name: Test code
27-
run: make test ZK_VERSION=${{ matrix.zk-version }}
28-
29-
- name: Upload code coverage
30-
uses: codecov/codecov-action@v1
31-
with:
32-
file: ./profile.cov
26+
- name: Run unittest ${{ matrix.go-version }}
27+
run: make unittest

CONTRIBUTION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## **Did you find a bug?**
44

5-
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/go-zookeper/zk/issues).
5+
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/go-zookeeper/zk/issues).
66

77
* If you're unable to find an open issue addressing the problem, open a new one.
88
* Be sure to include a title and clear description.

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ lint:
3737
build:
3838
go build ./...
3939

40+
.PHONY: unittest
41+
unittest:
42+
go test -timeout 500s -v -race -covermode atomic -skip=Integration ./...
43+
4044
.PHONY: test
4145
test: build zookeeper
4246
go test -timeout 500s -v -race -covermode atomic -coverprofile=profile.cov $(PACKAGES)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Native Go Zookeeper Client Library
22
===================================
33

44
[![GoDoc](https://godoc.org/github.com/go-zookeeper/zk?status.svg)](https://godoc.org/github.com/go-zookeeper/zk)
5-
[![Build Status](https://img.shields.io/github/workflow/status/go-zookeeper/zk/unittest/master)](https://github.com/go-zookeeper/zk/actions?query=branch%3Amaster)
5+
[![unittest](https://github.com/go-zookeeper/zk/actions/workflows/unittest.yaml/badge.svg?branch=master&event=push)](https://github.com/go-zookeeper/zk/actions/workflows/unittest.yaml)
66
[![Coverage Status](https://img.shields.io/codecov/c/github/go-zookeeper/zk/master)](https://codecov.io/gh/go-zookeeper/zk/branch/master)
77

88
License
99
-------
1010

11-
3-clause BSD. See LICENSE file.
11+
3-clause BSD. See [LICENSE](LICENSE) file.

cluster_test.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func (lw logWriter) Write(b []byte) (int, error) {
1616
return len(b), nil
1717
}
1818

19-
func TestBasicCluster(t *testing.T) {
19+
func TestIntegration_BasicCluster(t *testing.T) {
2020
ts, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
2121
if err != nil {
2222
t.Fatal(err)
@@ -33,8 +33,6 @@ func TestBasicCluster(t *testing.T) {
3333
}
3434
defer zk2.Close()
3535

36-
time.Sleep(time.Second * 5)
37-
3836
if _, err := zk1.Create("/gozk-test", []byte("foo-cluster"), 0, WorldACL(PermAll)); err != nil {
3937
t.Fatalf("Create failed on node 1: %+v", err)
4038
}
@@ -51,7 +49,7 @@ func TestBasicCluster(t *testing.T) {
5149
}
5250

5351
// If the current leader dies, then the session is reestablished with the new one.
54-
func TestClientClusterFailover(t *testing.T) {
52+
func TestIntegration_ClientClusterFailover(t *testing.T) {
5553
tc, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
5654
if err != nil {
5755
t.Fatal(err)
@@ -93,7 +91,7 @@ func TestClientClusterFailover(t *testing.T) {
9391

9492
// If a ZooKeeper cluster looses quorum then a session is reconnected as soon
9593
// as the quorum is restored.
96-
func TestNoQuorum(t *testing.T) {
94+
func TestIntegration_NoQuorum(t *testing.T) {
9795
tc, err := StartTestCluster(t, 3, nil, logWriter{t: t, p: "[ZKERR] "})
9896
if err != nil {
9997
t.Fatal(err)
@@ -189,7 +187,7 @@ func TestNoQuorum(t *testing.T) {
189187
}
190188
}
191189

192-
func TestWaitForClose(t *testing.T) {
190+
func TestIntegration_WaitForClose(t *testing.T) {
193191
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
194192
if err != nil {
195193
t.Fatal(err)
@@ -225,7 +223,7 @@ CONNECTED:
225223
}
226224
}
227225

228-
func TestBadSession(t *testing.T) {
226+
func TestIntegration_BadSession(t *testing.T) {
229227
ts, err := StartTestCluster(t, 1, nil, logWriter{t: t, p: "[ZKERR] "})
230228
if err != nil {
231229
t.Fatal(err)

0 commit comments

Comments
 (0)