Skip to content

Commit

Permalink
DAOS-15038 test: Parsing NVMe controller details from SMD info JSON i…
Browse files Browse the repository at this point in the history
…s failing (#13630)

* DAOS-15038 test: Parsing device state from SMD info JSON is failing

JSON output format of dmg storage query list-devices changed in
commit 8e1c846 and specifically
dev_state was moved to a ctrlr sub-node of smd_info. This has broken
src/common/tests_dmg_helpers.c:parse_device_info() which looks for
dev_state in smd_info. This change updates the function to look
for dev_state inside the ctrlr sub-node.


#Pragmas from previous commit message:
Skip-checkpatch: true
Skip-python-bandit: true
Skip-build: true
Quick-build: true
Quick-Functional: true
Allow-unstable-test: true
#RPM-test-version: version[-release]
#RPM-test-version: 2.5.100
# VM1-label: ci_vm1
# Ubuntu-VM9-label: ci_vm9
# Leap15-VM9-label: ci_vm9
# EL8-VM9-label: ci_vm9
# HW-medium-label: ci_nvme5
# HW-large-label: ci_nvme9
Signed-off-by: Tom Nabarro <[email protected]>
  • Loading branch information
tanabarr authored and brianjmurrell committed Jan 31, 2024
1 parent e51f5a8 commit 95683aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
36 changes: 23 additions & 13 deletions src/common/tests_dmg_helpers.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2020-2023 Intel Corporation.
* (C) Copyright 2020-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -1177,6 +1177,7 @@ parse_device_info(struct json_object *smd_dev, device_list *devices,
{
struct json_object *tmp;
struct json_object *dev = NULL;
struct json_object *ctrlr = NULL;
struct json_object *target = NULL;
struct json_object *targets;
int tgts_len;
Expand Down Expand Up @@ -1226,19 +1227,24 @@ parse_device_info(struct json_object *smd_dev, device_list *devices,
}
devices[*disks].n_tgtidx = tgts_len;

if (!json_object_object_get_ex(dev, "dev_state", &tmp)) {
D_ERROR("unable to extract state from JSON\n");
if (!json_object_object_get_ex(dev, "rank", &tmp)) {
D_ERROR("unable to extract rank from JSON\n");
return -DER_INVAL;
}
devices[*disks].rank = atoi(json_object_to_json_string(tmp));

snprintf(devices[*disks].state, sizeof(devices[*disks].state),
"%s", json_object_to_json_string(tmp));
if (!json_object_object_get_ex(dev, "ctrlr", &ctrlr)) {
D_ERROR("unable to extract ctrlr obj from JSON\n");
return -DER_INVAL;
}

if (!json_object_object_get_ex(dev, "rank", &tmp)) {
D_ERROR("unable to extract rank from JSON\n");
if (!json_object_object_get_ex(ctrlr, "dev_state", &tmp)) {
D_ERROR("unable to extract state from JSON\n");
return -DER_INVAL;
}
devices[*disks].rank = atoi(json_object_to_json_string(tmp));

snprintf(devices[*disks].state, sizeof(devices[*disks].state), "%s",
json_object_to_json_string(tmp));
*disks = *disks + 1;
}

Expand Down Expand Up @@ -1380,9 +1386,10 @@ dmg_storage_query_device_health(const char *dmg_config_file, char *host,
struct json_object *storage_map = NULL;
struct json_object *smd_info = NULL;
struct json_object *storage_info = NULL;
struct json_object *health_info = NULL;
struct json_object *health_stats = NULL;
struct json_object *devices = NULL;
struct json_object *dev_info = NULL;
struct json_object *ctrlr_info = NULL;
struct json_object *tmp = NULL;
char uuid_str[DAOS_UUID_STR_SIZE];
int argcount = 0;
Expand Down Expand Up @@ -1429,10 +1436,13 @@ dmg_storage_query_device_health(const char *dmg_config_file, char *host,
}

dev_info = json_object_array_get_idx(devices, 0);
json_object_object_get_ex(dev_info, "health", &health_info);
if (health_info != NULL) {
json_object_object_get_ex(health_info, stats,
&tmp);
if (!json_object_object_get_ex(dev_info, "ctrlr", &ctrlr_info)) {
D_ERROR("unable to extract ctrlr details from JSON\n");
D_GOTO(out_json, rc = -DER_INVAL);
}
json_object_object_get_ex(ctrlr_info, "health_stats", &health_stats);
if (health_stats != NULL) {
json_object_object_get_ex(health_stats, stats, &tmp);
strcpy(stats, json_object_to_json_string(tmp));
}
}
Expand Down
17 changes: 0 additions & 17 deletions src/tests/suite/daos_nvme_recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,23 +724,6 @@ nvme_test_simulate_IO_error(void **state)
print_message("Final read_errors = %s\n", check_errors);
assert_true(atoi(check_errors) == atoi(read_errors) + 1);

/*
* Verify writeErr=true and readErr:true available in control log
*/
char control_err[][50] = {
"detected blob I/O error! writeErr:true",
"detected blob I/O error! readErr:true"};
for (i = 0; i < 2 ; i++) {
rc = verify_state_in_log(devices[rank_pos].host,
control_log_file, control_err[i]);
if (rc != 0) {
print_message(
" %s not found in log %s\n", control_err[i],
control_log_file);
assert_rc_equal(rc, 0);
}
}

/* Tear down */
D_FREE(ow_buf);
D_FREE(fbuf);
Expand Down

0 comments on commit 95683aa

Please sign in to comment.