Skip to content

Commit 3c31018

Browse files
committed
Improve scripts for CI, -- output: test.env
1 parent 900053e commit 3c31018

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

.github/workflows/on_pull_request.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ jobs:
6969
sleep 10
7070
kafkacat -L -b 127.0.0.1:40091
7171
# run tests
72-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
72+
cat test.env
73+
source test.env
74+
ctest -VV
7375
# stop kafka cluster
7476
kafka-server-stop.sh
7577
zookeeper-server-stop.sh
@@ -137,7 +139,9 @@ jobs:
137139
sleep 10
138140
kafkacat -L -b 127.0.0.1:40091
139141
# run tests
140-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
142+
cat test.env
143+
source test.env
144+
ctest -VV
141145
# stop kafka cluster
142146
kafka-server-stop.sh
143147
zookeeper-server-stop.sh
@@ -205,7 +209,9 @@ jobs:
205209
sleep 10
206210
kafkacat -L -b 127.0.0.1:40091
207211
# run tests
208-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
212+
cat test.env
213+
source test.env
214+
ctest -VV
209215
# stop kafka cluster
210216
kafka-server-stop.sh
211217
zookeeper-server-stop.sh
@@ -273,7 +279,9 @@ jobs:
273279
sleep 10
274280
kafkacat -L -b 127.0.0.1:40091
275281
# run tests
276-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
282+
cat test.env
283+
source test.env
284+
ctest -VV
277285
# stop kafka cluster
278286
kafka-server-stop.sh
279287
zookeeper-server-stop.sh
@@ -340,7 +348,9 @@ jobs:
340348
sleep 10
341349
kafkacat -L -b 127.0.0.1:40091
342350
# run tests
343-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
351+
cat test.env
352+
source test.env
353+
ctest -VV
344354
# stop kafka cluster
345355
kafka-server-stop.sh
346356
zookeeper-server-stop.sh
@@ -407,7 +417,9 @@ jobs:
407417
sleep 10
408418
kafkacat -L -b 127.0.0.1:40091
409419
# run tests
410-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
420+
cat test.env
421+
source test.env
422+
ctest -VV
411423
# stop kafka cluster
412424
kafka-server-stop.sh
413425
zookeeper-server-stop.sh
@@ -475,7 +487,9 @@ jobs:
475487
sleep 10
476488
kafkacat -L -b 127.0.0.1:40091
477489
# run tests
478-
export KAFKA_BROKER_LIST="127.0.0.1:40091,127.0.0.1:40092,127.0.0.1:40093"; ctest -VV
490+
cat test.env
491+
source test.env
492+
ctest -VV
479493
# stop kafka cluster
480494
kafka-server-stop.sh
481495
zookeeper-server-stop.sh

include/kafka/Project.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#define KAFKA_API kafka
66
#endif
77

8-
// Here is the MACRO to enable UT stubs
8+
// Here is the MACRO to enable internal stubs for UT
99
// #ifndef KAFKA_API_ENABLE_UNIT_TEST_STUBS
1010
// #define KAFKA_API_ENABLE_UNIT_TEST_STUBS
11-
// #endif
11+
// #endif
12+

scripts/start-local-kafka-cluster.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,20 @@ def addProcess(self, cmd, name, outFile, errFile):
3535
stdout=out,
3636
stderr=err)
3737

38-
print('name: {0}, pid: {1}'.format(name, p.pid))
39-
4038
if 'kafka' in name:
4139
kafkaPids.append(p.pid)
4240
else:
4341
zookeeperPids.append(p.pid)
4442

4543
self.processList.append((p, name))
4644

47-
4845
def run(self):
4946
anyFailure = False
5047
while self.processList:
5148
for (i, (p, name)) in enumerate(self.processList):
5249
ret = p.poll()
5350
if ret != None:
54-
print('failed: {0}, pid: {1}, ret: {2}'.format(name, p.pid, ret))
51+
print('Failed to start server: {0}, pid: {1}, ret: {2}'.format(name, p.pid, ret))
5552
self.processList.pop(i)
5653
anyFailure = True
5754
break
@@ -60,8 +57,8 @@ def run(self):
6057

6158
def terminate(self):
6259
for (p, name) in self.processList:
63-
print('terminate: {0}, pid: {1}'.format(name, p.pid))
6460
p.kill()
61+
print('{0} terminated'.format(name))
6562

6663
def __del__(self):
6764
self.terminate()
@@ -143,6 +140,10 @@ def main():
143140

144141
print('Kafka server started... (zookeeper pid: {0}, kafka pids: {1})'.format(zookeeperPids, kafkaPids))
145142

143+
with open(r'test.env', 'w') as envFile:
144+
envFile.write('export KAFKA_BROKER_LIST={0}\n'.format(','.join(['127.0.0.1:{0}'.format(port) for port in brokerPorts])))
145+
envFile.write('export KAFKA_BROKER_PIDS={0}\n'.format(','.join([str(pid) for pid in kafkaPids])))
146+
146147
processPool.run()
147148

148149

0 commit comments

Comments
 (0)