Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-15038 test: Parsing NVMe controller details from SMD info JSON is failing #13630

Merged
merged 6 commits into from
Jan 30, 2024
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 @@ -1074,6 +1074,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 @@ -1123,19 +1124,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 @@ -1277,9 +1283,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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT indentation issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix these either if I repush or in a subsequent PR

struct json_object *devices = NULL;
struct json_object *dev_info = NULL;
struct json_object *ctrlr_info = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT indentation issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix these either if I repush or in a subsequent PR

struct json_object *tmp = NULL;
char uuid_str[DAOS_UUID_STR_SIZE];
int argcount = 0;
Expand Down Expand Up @@ -1326,10 +1333,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
Loading