Skip to content

Commit 1ec1938

Browse files
committed
test: add more healthfile tests
1 parent fb05bb7 commit 1ec1938

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

axiom/tests/test_health.c

+29-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
#include "util_memory.h"
1515

1616
#include "tlib_main.h"
17+
#include "util_strings.h"
1718
#include "util_syscalls.h"
1819

1920
static void test_health(void) {
2021
nr_status_t rv;
2122
char* location = NULL;
23+
char* rand_uuid = NULL;
24+
char* rand_healthfile = NULL;
2225

2326
nrh_set_start_time();
2427

@@ -29,42 +32,60 @@ static void test_health(void) {
2932
tlib_pass_if_true("initialization to bad path fails", NULL == location,
3033
"location=%s", NULL == location ? "NULL" : location);
3134
nr_free(location);
32-
3335
rv = nrh_set_uuid("bc21b5891f5e44fc9272caef924611a");
3436
tlib_pass_if_true("set uuid with invalid length uuid fails", NR_FAILURE == rv,
3537
"rv=%d", (int)rv);
3638

37-
rv = nrh_set_uuid("ffffffffffffffffffffffffffffffff");
38-
tlib_pass_if_true("set uuid succeeds", NR_SUCCESS == rv, "rv=%d", (int)rv);
39-
4039
location = nrh_get_health_location("file://./");
4140
tlib_pass_if_true("initialization to good path succeeds", NULL != location,
4241
"location=%s", NULL == location ? "NULL" : location);
42+
rv = nrh_set_last_error(NRH_INVALID_LICENSE);
43+
rv = nrh_write_health(location);
44+
tlib_pass_if_true("health file write succeeds", NR_SUCCESS == rv, "rv=%d",
45+
(int)rv);
46+
tlib_pass_if_exists("./health-bc21b5891f5e44fc9272caef924611a8.yml");
4347

48+
rv = nrh_set_uuid("ffffffffffffffffffffffffffffffff");
49+
tlib_pass_if_true("set uuid succeeds", NR_SUCCESS == rv, "rv=%d", (int)rv);
4450
rv = nrh_set_last_error(NRH_MISSING_LICENSE);
45-
4651
rv = nrh_write_health(location);
4752
tlib_pass_if_true("health file write succeeds", NR_SUCCESS == rv, "rv=%d",
4853
(int)rv);
49-
5054
tlib_pass_if_exists("./health-ffffffffffffffffffffffffffffffff.yml");
5155

5256
rv = nrh_set_last_error(NRH_MISSING_APPNAME);
53-
5457
rv = nrh_write_health(location);
5558
tlib_pass_if_true("write_health succeeds", NR_SUCCESS == rv, "rv=%d",
5659
(int)rv);
5760

5861
rv = nrh_set_last_error(NRH_HEALTHY);
59-
6062
rv = nrh_write_health(location);
6163
tlib_pass_if_true("write_health succeeds", NR_SUCCESS == rv, "rv=%d",
6264
(int)rv);
6365

66+
rv = nrh_set_uuid(NULL);
67+
tlib_pass_if_true("set random uuid succeeds", NR_SUCCESS == rv, "rv=%d",
68+
(int)rv);
69+
rand_uuid = nrh_get_uuid();
70+
tlib_pass_if_not_null("get uuid succeeds", rand_uuid);
71+
tlib_pass_if_true(
72+
"manual uuid successfully replaced by random uuid",
73+
0 != nr_strcmp("ffffffffffffffffffffffffffffffff", rand_uuid), "rand=%s",
74+
rand_uuid);
75+
rv = nrh_set_last_error(NRH_CONNECTION_FAILED);
76+
rv = nrh_write_health(location);
77+
78+
rand_healthfile = nrh_get_health_filename();
79+
tlib_pass_if_not_null("get health filename succeeds", rand_healthfile);
80+
tlib_pass_if_exists(rand_healthfile);
81+
6482
nr_unlink("health-bc21b5891f5e44fc9272caef924611a8.yml");
6583
nr_unlink("health-ffffffffffffffffffffffffffffffff.yml");
84+
nr_unlink(rand_healthfile);
6685

6786
nr_free(location);
87+
nr_free(rand_uuid);
88+
nr_free(rand_healthfile);
6889
}
6990

7091
tlib_parallel_info_t parallel_info

0 commit comments

Comments
 (0)