Skip to content

Commit 67bbe1b

Browse files
adityaagg09rahulrane50tisonkundesaikomalabhilash1in
authored
[LIZK-4062] [Build-related-change] Consolidate all the build/test related change/configuration into a single commit for future upgrade integration (#139)
* ZOOKEEPER-4480: Introduce end to end compatibility tests (#106) Cherry picked e2e tests from upstream. This checks basic backward compatibility and regression testing. For original PR : apache/zookeeper@609afd1 Co-authored-by: tison <wander4096@gmail.com> * Fix the build for branch-3.6 (#115) This has merged all the changes from li-dev branch. There is still a problem where it is not able to find snapshot as it needs to look at the local m2 repository. * [LIZK-4062] [Build-related-change] Consolidate all the build/test related change/configuration into a single commit for future upgrade integration --------- Co-authored-by: Rahul Rane <rahulrane50@gmail.com> Co-authored-by: tison <wander4096@gmail.com> Co-authored-by: Komal Desai <98000016+desaikomal@users.noreply.github.com> Co-authored-by: Abhilash Kishore <abhilash1in@gmail.com>
1 parent 32a1e91 commit 67bbe1b

13 files changed

Lines changed: 345 additions & 63 deletions

File tree

.github/workflows/ci-jfrog-workflow.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ name: Publish to LinkedIn JFrog
2020

2121
on:
2222
release:
23-
branches:
24-
- 'li-dev/**'
2523
types: [published]
2624
jobs:
2725
deploy:

.github/workflows/ci.yaml

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
# Licensed to the Apache Software Foundation (ASF) under one
32
# or more contributor license agreements. See the NOTICE file
43
# distributed with this work for additional information
@@ -15,7 +14,6 @@
1514
# KIND, either express or implied. See the License for the
1615
# specific language governing permissions and limitations
1716
# under the License.
18-
#
1917

2018
# This workflow will build a Java project with Maven
2119
# See also:
@@ -50,39 +48,48 @@ jobs:
5048
timeout-minutes: 360
5149
runs-on: ubuntu-latest
5250
steps:
53-
- uses: actions/checkout@v2
54-
- name: Set up JDK ${{ matrix.profile.jdk }}
55-
uses: actions/setup-java@v1
56-
with:
57-
java-version: ${{ matrix.profile.jdk }}
58-
- name: Cache local maven repository
59-
uses: actions/cache@v2
60-
with:
61-
path: |
62-
~/.m2/repository/
63-
!~/.m2/repository/org/apache/zookeeper
64-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
65-
restore-keys: ${{ runner.os }}-m2
66-
- name: Show the first log message
67-
run: git log -n1
68-
- name: Install C Dependencies
69-
run: sudo apt-get install libcppunit-dev libsasl2-dev
70-
- name: Build with Maven (${{ matrix.profile.name }})
71-
run: mvn -B -V -e -ntp "-Dstyle.color=always" ${{ matrix.profile.args }}
72-
env:
73-
MAVEN_OPTS: -Djansi.force=true
74-
- name: Upload unit test results
75-
if: ${{ failure() }}
76-
uses: actions/upload-artifact@v2
77-
with:
78-
name: surefire-reports-${{ matrix.profile.name }}
79-
path: ./**/target/surefire-reports/
80-
if-no-files-found: ignore
81-
- name: Upload integration test results
82-
if: ${{ failure() }}
83-
uses: actions/upload-artifact@v2
84-
with:
85-
name: failsafe-reports-${{ matrix.profile.name }}
86-
path: ./**/target/failsafe-reports/
87-
if-no-files-found: ignore
88-
51+
- uses: actions/checkout@v3
52+
- name: Set up JDK ${{ matrix.profile.jdk }}
53+
uses: actions/setup-java@v3
54+
with:
55+
java-version: ${{ matrix.profile.jdk }}
56+
distribution: temurin
57+
- name: Cache local maven repository
58+
uses: actions/cache@v3
59+
with:
60+
path: |
61+
~/.m2/repository/
62+
!~/.m2/repository/org/apache/zookeeper
63+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
64+
restore-keys: ${{ runner.os }}-m2
65+
- name: Show the first log message
66+
run: git log -n1
67+
- name: Install C Dependencies
68+
run: |
69+
sudo apt update
70+
sudo apt install -y libcppunit-dev libsasl2-dev
71+
- name: Build with Maven (${{ matrix.profile.name }})
72+
run: mvn -B -V -e -ntp "-Dstyle.color=always" ${{ matrix.profile.args }}
73+
env:
74+
MAVEN_OPTS: -Djansi.force=true
75+
- name: Upload unit test results
76+
if: ${{ failure() }}
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: surefire-reports-${{ matrix.profile.name }}
80+
path: ./**/target/surefire-reports/
81+
if-no-files-found: ignore
82+
- name: Upload integration test results
83+
if: ${{ failure() }}
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: failsafe-reports-${{ matrix.profile.name }}
87+
path: ./**/target/failsafe-reports/
88+
if-no-files-found: ignore
89+
- name: Upload cppunit test logs
90+
if: ${{ failure() }}
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: cppunit-logs-${{ matrix.profile.name }}
94+
path: ./zookeeper-client/zookeeper-client-c/target/c/TEST-*.txt
95+
if-no-files-found: ignore

.github/workflows/e2e.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: End to End Tests
19+
20+
on:
21+
push:
22+
pull_request:
23+
24+
jobs:
25+
compatibility:
26+
strategy:
27+
matrix:
28+
jdk: [8, 11]
29+
zk: [3.5.9, 3.6.3, 3.7.0, nightly]
30+
fail-fast: false
31+
timeout-minutes: 360
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v3
35+
- name: Set up JDK ${{ matrix.jdk }}
36+
uses: actions/setup-java@v3
37+
with:
38+
java-version: ${{ matrix.jdk }}
39+
distribution: temurin
40+
- name: Cache local maven repository
41+
uses: actions/cache@v3
42+
with:
43+
path: |
44+
~/.m2/repository/
45+
!~/.m2/repository/org/apache/zookeeper
46+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
47+
restore-keys: ${{ runner.os }}-m2
48+
- name: Show the first log message
49+
run: git log -n1
50+
- name: Install C Dependencies
51+
run: |
52+
sudo apt update
53+
sudo apt install -y libcppunit-dev libsasl2-dev
54+
- name: Build with Maven
55+
run: mvn -B -V -e -ntp "-Dstyle.color=always" package -DskipTests
56+
env:
57+
MAVEN_OPTS: -Djansi.force=true
58+
- name: Download ZooKeeper ${{ matrix.zk }}
59+
if: matrix.zk != 'nightly'
60+
run: |
61+
curl -O https://archive.apache.org/dist/zookeeper/zookeeper-${{ matrix.zk }}/apache-zookeeper-${{ matrix.zk }}-bin.tar.gz
62+
tar -xzvf apache-zookeeper-${{ matrix.zk }}-bin.tar.gz
63+
- name: Test ZooKeeper nightly server and ${{ matrix.zk }} client
64+
if: matrix.zk != 'nightly'
65+
run: tools/ci/test-connectivity.py --server . --client apache-zookeeper-${{ matrix.zk }}-bin
66+
env:
67+
ZOOCFG: zoo_sample.cfg
68+
- name: Test ZooKeeper ${{ matrix.zk }} server and nightly client
69+
if: matrix.zk != 'nightly'
70+
run: tools/ci/test-connectivity.py --server apache-zookeeper-${{ matrix.zk }}-bin --client .
71+
env:
72+
ZOOCFG: zoo_sample.cfg
73+
- name: Test ZooKeeper nightly server and client
74+
if: matrix.zk == 'nightly'
75+
run: tools/ci/test-connectivity.py --server . --client .
76+
env:
77+
ZOOCFG: zoo_sample.cfg

.github/workflows/manual.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ jobs:
7070
MAVEN_OPTS: -Djansi.force=true
7171
- name: Upload unit test results
7272
if: ${{ failure() }}
73-
uses: actions/upload-artifact@v2
73+
uses: actions/upload-artifact@v4
7474
with:
7575
name: surefire-reports
7676
path: ./**/target/surefire-reports/
7777
if-no-files-found: ignore
7878
- name: Upload integration test results
7979
if: ${{ failure() }}
80-
uses: actions/upload-artifact@v2
80+
uses: actions/upload-artifact@v4
8181
with:
8282
name: failsafe-reports
8383
path: ./**/target/failsafe-reports/

tools/ci/test-connectivity.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
import argparse
20+
import subprocess
21+
22+
from pathlib import Path
23+
24+
class Server():
25+
def __init__(self, binpath):
26+
self.binpath = binpath
27+
def __enter__(self):
28+
subprocess.run([f'{self.binpath}', 'start'], check=True)
29+
return self
30+
def __exit__(self, type, value, traceback):
31+
subprocess.run([f'{self.binpath}', 'stop'], check=True)
32+
33+
if __name__ == '__main__':
34+
parser = argparse.ArgumentParser()
35+
parser.add_argument('--server', help="basepath to zk server", required=True)
36+
parser.add_argument('--client', help="basepath to zk client", required=True)
37+
38+
args = parser.parse_args()
39+
40+
server_basepath = Path(args.server).absolute()
41+
server_binpath = server_basepath / "bin" / "zkServer.sh"
42+
assert server_binpath.exists(), f"server binpath not exist: {server_binpath}"
43+
client_basepath = Path(args.client).absolute()
44+
client_binpath = client_basepath / "bin" / "zkCli.sh"
45+
assert client_binpath.exists(), f"client binpath not exist: {client_binpath}"
46+
47+
with Server(server_binpath):
48+
subprocess.run([f'{client_binpath}', 'sync', '/'], check=True)

zookeeper-assembly/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,11 @@
170170
</plugin>
171171
</plugins>
172172
</build>
173-
173+
<distributionManagement>
174+
<repository>
175+
<id>jfrog-linkedin</id>
176+
<name>linkedin-releases</name>
177+
<url>https://linkedin.jfrog.io/artifactory/zookeeper</url>
178+
</repository>
179+
</distributionManagement>
174180
</project>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <cppunit/extensions/HelperMacros.h>
20+
#include "CppAssertHelper.h"
21+
22+
#include <sys/socket.h>
23+
#include <unistd.h>
24+
25+
#include <zookeeper.h>
26+
27+
#include "Util.h"
28+
#include "WatchUtil.h"
29+
30+
ZOOAPI int zoo_create2(zhandle_t *zh, const char *path, const char *value,
31+
int valuelen, const struct ACL_vector *acl, int mode,
32+
char *path_buffer, int path_buffer_len, struct Stat *stat);
33+
34+
class Zookeeper_serverRequireClientSASL : public CPPUNIT_NS::TestFixture {
35+
CPPUNIT_TEST_SUITE(Zookeeper_serverRequireClientSASL);
36+
#ifdef THREADED
37+
CPPUNIT_TEST(testServerRequireClientSASL);
38+
#endif
39+
CPPUNIT_TEST_SUITE_END();
40+
FILE *logfile;
41+
static const char hostPorts[];
42+
static void watcher(zhandle_t *, int type, int state, const char *path,void*v){
43+
watchctx_t *ctx = (watchctx_t*)v;
44+
45+
if (state == ZOO_CONNECTED_STATE) {
46+
ctx->connected = true;
47+
} else {
48+
ctx->connected = false;
49+
}
50+
if (type != ZOO_SESSION_EVENT) {
51+
evt_t evt;
52+
evt.path = path;
53+
evt.type = type;
54+
ctx->putEvent(evt);
55+
}
56+
}
57+
58+
public:
59+
Zookeeper_serverRequireClientSASL() {
60+
logfile = openlogfile("Zookeeper_serverRequireClientSASL");
61+
}
62+
63+
~Zookeeper_serverRequireClientSASL() {
64+
if (logfile) {
65+
fflush(logfile);
66+
fclose(logfile);
67+
logfile = 0;
68+
}
69+
}
70+
71+
void setUp() {
72+
zoo_set_log_stream(logfile);
73+
zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG);
74+
stopServer();
75+
}
76+
77+
void tearDown() {
78+
startServer();
79+
}
80+
81+
void startServer() {
82+
char cmd[1024];
83+
sprintf(cmd, "%s start", ZKSERVER_CMD);
84+
CPPUNIT_ASSERT(system(cmd) == 0);
85+
}
86+
87+
void startServerRequireSASLAuth() {
88+
char cmd[1024];
89+
sprintf(cmd, "%s startRequireSASLAuth", ZKSERVER_CMD);
90+
CPPUNIT_ASSERT(system(cmd) == 0);
91+
}
92+
93+
void stopServer() {
94+
char cmd[1024];
95+
sprintf(cmd, "%s stop", ZKSERVER_CMD);
96+
CPPUNIT_ASSERT(system(cmd) == 0);
97+
}
98+
99+
void testServerRequireClientSASL() {
100+
startServerRequireSASLAuth();
101+
102+
watchctx_t ctx;
103+
int rc = 0;
104+
zhandle_t *zk = zookeeper_init(hostPorts, watcher, 10000, 0, &ctx, 0);
105+
ctx.zh = zk;
106+
CPPUNIT_ASSERT(zk);
107+
108+
char pathbuf[80];
109+
struct Stat stat_a = {0};
110+
111+
rc = zoo_create2(zk, "/serverRequireClientSASL", "", 0,
112+
&ZOO_OPEN_ACL_UNSAFE, 0, pathbuf, sizeof(pathbuf), &stat_a);
113+
CPPUNIT_ASSERT_EQUAL((int)ZSESSIONCLOSEDREQUIRESASLAUTH, rc);
114+
115+
stopServer();
116+
}
117+
};
118+
119+
const char Zookeeper_serverRequireClientSASL::hostPorts[] = "127.0.0.1:22181";
120+
121+
CPPUNIT_TEST_SUITE_REGISTRATION(Zookeeper_serverRequireClientSASL);

0 commit comments

Comments
 (0)