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

Fix liveliness CI test #827

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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
8 changes: 5 additions & 3 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,14 @@ jobs:
- name: Install valgrind
run: sudo apt install -y valgrind

- name: Build project and run test
- name: Build project
run: |
sudo apt install -y ninja-build
Z_FEATURE_UNSTABLE_API=1 Z_FEATURE_LIVELINESS=1 CMAKE_GENERATOR=Ninja make
python3 ./build/tests/memory_leak.py
timeout-minutes: 5

- name: Run test
run: python3 -u ./build/tests/memory_leak.py
timeout-minutes: 5

- name: Kill Zenoh router
if: always()
Expand Down
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Z_FEATURE_SUBSCRIPTION?=1
Z_FEATURE_QUERY?=1
Z_FEATURE_QUERYABLE?=1
Z_FEATURE_INTEREST?=1
Z_FEATURE_LIVELINESS?=1
Z_FEATURE_RAWETH_TRANSPORT?=0

# Buffer sizes
Expand Down
23 changes: 10 additions & 13 deletions examples/unix/c11/z_liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>

#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -20,21 +19,15 @@

#if Z_FEATURE_LIVELINESS == 1

static volatile int keepRunning = 1;

void intHandler(int dummy) {
(void)dummy;
keepRunning = 0;
}

int main(int argc, char **argv) {
const char *keyexpr = "group1/zenoh-pico";
const char *mode = "client";
const char *clocator = NULL;
const char *llocator = NULL;
unsigned int timeout = 0;

int opt;
while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) {
while ((opt = getopt(argc, argv, "k:e:m:l:t:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
Expand All @@ -48,8 +41,12 @@ int main(int argc, char **argv) {
case 'l':
llocator = optarg;
break;
case 't':
timeout = atoi(optarg);
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') {
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l' ||
optopt == 't') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand Down Expand Up @@ -98,9 +95,9 @@ int main(int argc, char **argv) {
}

printf("Press CTRL-C to undeclare liveliness token and quit...\n");
signal(SIGINT, intHandler);
while (keepRunning) {
z_sleep_s(1);
z_clock_t clock = z_clock_now();
while (timeout == 0 || z_clock_elapsed_s(&clock) < timeout) {
z_sleep_ms(100);
}

// LivelinessTokens are automatically closed when dropped
Expand Down
6 changes: 3 additions & 3 deletions tests/memory_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def query_and_queryable(query_cmd, queryable_cmd):
z_query_process.wait()

print(f"Stop {queryable_cmd}")
time.sleep(2)
time.sleep(5)
if z_queryable_process.poll() is None:
# send SIGINT to group
z_quaryable_process_gid = os.getpgid(z_queryable_process.pid)
Expand Down Expand Up @@ -176,11 +176,11 @@ def query_and_queryable(query_cmd, queryable_cmd):
EXIT_STATUS = 1
# Test liveliness query
print("*** Get liveliness test ***")
if query_and_queryable('z_get_liveliness', 'z_liveliness') == 1:
if query_and_queryable('z_get_liveliness', 'z_liveliness -t 3') == 1:
EXIT_STATUS = 1
# Test liveliness subscriber
print("*** Liveliness subscriber test ***")
if query_and_queryable('z_sub_liveliness -h -n 1', 'z_liveliness') == 1:
if query_and_queryable('z_liveliness -t 1', 'z_sub_liveliness -h -n 1') == 1:
EXIT_STATUS = 1
# Exit
sys.exit(EXIT_STATUS)
Loading