Skip to content

Commit

Permalink
* MDF [unit test] a little adjustment.
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann0222 <yukang.wei@emqx.io>
  • Loading branch information
OdyWayne committed Sep 20, 2023
1 parent 7b5a68f commit b36e8fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
4 changes: 1 addition & 3 deletions nanomq/tests/bridge_rap_rh_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ main()
memset(buf_rh0, 0, buf_size);
memset(buf_rh1, 0, buf_size);
memset(buf_rh2, 0, buf_size);
printf("\ntest\n");

// pub the retain msgs.
p_pub_emqx_rap0 = popen(cmd_pub_emqx_rap0, "r");
p_pub_emqx_rh0 = popen(cmd_pub_emqx_rh0, "r");
p_pub_emqx_rh1 = popen(cmd_pub_emqx_rh1, "r");
p_pub_emqx_rh2 = popen(cmd_pub_emqx_rh2, "r");
nng_msleep(1500);
nng_msleep(2000);
// create nmq thread
conf = get_test_conf(BRIDGE_CONF);
assert(conf != NULL);
Expand Down
9 changes: 7 additions & 2 deletions nanomq/tests/http_server_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,19 @@ main()
{
char *cmd = "mosquitto_sub -h 127.0.0.1 -p 1881 -t topic-test -u "
"user-test -i clientid-test";
char *cmd2 = "mosquitto_sub -h 127.0.0.1 -p 1881 -t topic-test2 -u "
"user-test -i clientid-test";
nng_thread *nmq;
conf *conf;
FILE *fd;
FILE *fd2;

conf = get_test_conf(ALL_FEATURE_CONF);
assert(conf != NULL);
nng_thread_create(&nmq, (void *) broker_start_with_conf, (void *) conf);
// nng_msleep(100); // wait a while for broker to init
fd = popen(cmd, "r");
fd2 = popen(cmd2, "r");
nng_msleep(50); // wait a while after sub

// TODO: there is a potential connection refuse case & although they
Expand Down Expand Up @@ -632,8 +636,8 @@ main()
assert(test_get_bridges());
assert(test_get_bridge());
// TODO: rest api need change for topic reflection in bridge.
// assert(test_put_bridges_sub());
// assert(test_put_bridges_unsub());
assert(test_put_bridges_sub()); // this is not 100% right due to the new topic reflection
// assert(test_put_bridges_unsub()); // bridge unsub has to change for topic reflection
assert(test_put_bridges());

assert(test_post_rules());
Expand Down Expand Up @@ -661,6 +665,7 @@ main()
// assert(test_restart());
// assert(test_stop());
pclose(fd);
pclose(fd2);

nng_thread_destroy(nmq);
}
7 changes: 7 additions & 0 deletions nanomq/tests/nanomq_bridge_test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,28 @@ bridges.mqtt.emqx {
remote_topic = "recv/topic1"
local_topic = "recv_lo/topic1"
qos = 1
retain_as_published = 0
},
{
remote_topic = "recv/topic2"
local_topic = "recv_lo/topic2"
qos = 2
retain_as_published = 1
retain_handling = 0
},
{
remote_topic = "cmd/topic1"
local_topic = "cmd_lo/topic1"
qos = 1
retain_as_published = 1
retain_handling = 1
},
{
remote_topic = "cmd/topic2"
local_topic = "cmd_lo/topic2"
qos = 2
retain_as_published = 1
retain_handling = 2
}
]
max_parallel_processes = 2
Expand Down
7 changes: 7 additions & 0 deletions nanomq/tests/nanomq_bridge_tls_test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,28 @@ bridges.mqtt.emqx {
remote_topic = "recv/topic1"
local_topic = "recv_lo/topic1"
qos = 1
retain_as_published = 0
},
{
remote_topic = "recv/topic2"
local_topic = "recv_lo/topic2"
qos = 2
retain_as_published = 1
retain_handling = 0
},
{
remote_topic = "cmd/topic1"
local_topic = "cmd_lo/topic1"
qos = 1
retain_as_published = 1
retain_handling = 1
},
{
remote_topic = "cmd/topic2"
local_topic = "cmd_lo/topic2"
qos = 2
retain_as_published = 1
retain_handling = 2
}
]
max_parallel_processes = 2
Expand Down

0 comments on commit b36e8fd

Please sign in to comment.