Skip to content

Commit 92ac8d5

Browse files
committed
unit test
1 parent 5d165f2 commit 92ac8d5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

axiom/tests/test_segment_datastore.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,35 @@ static void test_create_metrics_no_table_no_operation(void) {
197197
nr_txn_destroy(&txn);
198198
}
199199

200+
static void test_create_metrics_instance_only(void) {
201+
nrtxn_t* txn = new_txn(0);
202+
nrtime_t duration = 4 * NR_TIME_DIVISOR;
203+
nr_segment_datastore_params_t params = sample_segment_datastore_params();
204+
nr_datastore_instance_t instance = {.host = "hostname",
205+
.port_path_or_id = "123",
206+
.database_name = "my database"};
207+
nr_segment_t* segment = NULL;
208+
char* tname = "create metrics";
209+
210+
params.instance = &instance;
211+
params.instance_only = true;
212+
segment = nr_segment_start(txn, NULL, NULL);
213+
segment->start_time = 1 * NR_TIME_DIVISOR;
214+
segment->stop_time = 1 * NR_TIME_DIVISOR + duration;
215+
216+
test_segment_datastore_end_and_keep(&segment, &params);
217+
218+
/*
219+
* Test : Create only the instance metric
220+
*/
221+
test_metric_vector_size(segment->metrics, 1);
222+
test_segment_metric_created(tname, segment->metrics,
223+
"Datastore/instance/MongoDB/hostname/123",
224+
false);
225+
226+
nr_txn_destroy(&txn);
227+
}
228+
200229
static void test_instance_info_reporting_disabled(void) {
201230
nrtxn_t* txn = new_txn(0);
202231
nrtime_t duration = 4 * NR_TIME_DIVISOR;
@@ -1127,6 +1156,7 @@ tlib_parallel_info_t parallel_info = {.suggested_nthreads = 2, .state_size = 0};
11271156
void test_main(void* p NRUNUSED) {
11281157
test_bad_parameters();
11291158
test_create_metrics();
1159+
test_create_metrics_instance_only();
11301160
test_create_metrics_no_table();
11311161
test_create_metrics_no_table_no_operation();
11321162
test_instance_info_reporting_disabled();

0 commit comments

Comments
 (0)