Skip to content

Commit

Permalink
* FIX [bridge test] fix the frequently failing ci in bridge test.
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann0222 <yukang.wei@emqx.io>
  • Loading branch information
OdyWayne committed Aug 28, 2023
1 parent 8680dd4 commit 8742901
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nanomq/apps/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ broker(conf *nanomq_conf)
conf *conf = works[0]->config;
if(is_testing == true && conf->bridge.count > 0) {
// bridge might need more time to response to the resquest
nng_msleep(4000);
nng_msleep(8 * 1000);
}
for (size_t t = 0; t < conf->bridge.count; t++) {
conf_bridge_node *node = conf->bridge.nodes[t];
Expand Down
8 changes: 6 additions & 2 deletions nanomq/tests/bridge_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@ main()
int outfp_nmq, outfp_emqx;
char buf_nmq[buf_size];
char buf_emqx[buf_size];
memset(buf_nmq, 0, buf_size);
memset(buf_emqx, 0, buf_size);

// create nmq thread
conf = get_test_conf(BRIDGE_CONF);
assert(conf != NULL);
nng_thread_create(&nmq, (void *) broker_start_with_conf, (void *) conf);
nng_msleep(50); // wait a while before sub
nng_msleep(2000); // wait a while before sub

pid_sub_nmq = popen_sub_with_cmd(&outfp_nmq, cmd_sub_nmq);
pid_sub_emqx = popen_sub_with_cmd(&outfp_emqx, cmd_sub_emqx);
nng_msleep(500);
nng_msleep(2000);
p_pub_emqx = popen(cmd_pub_emqx, "r");
p_pub_nmq= popen(cmd_pub_nmq, "r");
// check recv msg
assert(read(outfp_nmq, buf_nmq, buf_size) != -1);
printf("get the msg in nmq:%s\n", buf_nmq);
assert(strncmp(buf_nmq, "message-to-nmq", 14) == 0);
assert(read(outfp_emqx, buf_emqx, buf_size) != -1);
printf("get the msg in emqx:%s\n", buf_emqx);
assert(strncmp(buf_emqx, "message-to-emqx", 15) == 0);

kill(pid_sub_nmq, SIGKILL);
Expand Down
3 changes: 2 additions & 1 deletion nanomq/tests/tests_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ conf *
get_test_conf(conf_type type)
{
// get conf from file
conf *nmq_conf = NULL;
conf *nmq_conf = NULL;
char *conf_path = NULL;

if ((nmq_conf = nng_zalloc(sizeof(conf))) == NULL) {
return nmq_conf;
}
Expand Down

0 comments on commit 8742901

Please sign in to comment.