From e762ae7c2e7d7d14cf54d48002b764f22cce8753 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Tue, 6 Sep 2022 10:42:06 +0200 Subject: [PATCH 1/2] Add C tests for ADM_*_pfs_storage RPCs --- examples/c/ADM_register_pfs_storage.c | 94 +++++++++++++++++++++++++++ examples/c/ADM_remove_pfs_storage.c | 81 +++++++++++++++++++++++ examples/c/ADM_update_pfs_storage.c | 81 +++++++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100644 examples/c/ADM_register_pfs_storage.c create mode 100644 examples/c/ADM_remove_pfs_storage.c create mode 100644 examples/c/ADM_update_pfs_storage.c diff --git a/examples/c/ADM_register_pfs_storage.c b/examples/c/ADM_register_pfs_storage.c new file mode 100644 index 00000000..66af17f4 --- /dev/null +++ b/examples/c/ADM_register_pfs_storage.c @@ -0,0 +1,94 @@ +/****************************************************************************** + * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain + * + * This software was partially supported by the EuroHPC-funded project ADMIRE + * (Project ID: 956748, https://www.admire-eurohpc.eu). + * + * This file is part of scord. + * + * scord is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * scord is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with scord. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include +#include +#include + +#define NINPUTS 10 +#define NOUTPUTS 5 + +int +main(int argc, char* argv[]) { + + if(argc != 2) { + fprintf(stderr, "ERROR: no server address provided\n"); + fprintf(stderr, "Usage: ADM_register_pfs_storage \n"); + exit(EXIT_FAILURE); + } + + int exit_status = EXIT_SUCCESS; + ADM_server_t server = ADM_server_create("tcp", argv[1]); + + + ADM_dataset_t inputs[NINPUTS]; + + for(int i = 0; i < NINPUTS; ++i) { + const char* pattern = "input-dataset-%d"; + size_t n = snprintf(NULL, 0, pattern, i); + char* id = (char*) alloca(n + 1); + snprintf(id, n + 1, pattern, i); + inputs[i] = ADM_dataset_create(id); + } + + ADM_dataset_t outputs[NOUTPUTS]; + + for(int i = 0; i < NOUTPUTS; ++i) { + const char* pattern = "output-dataset-%d"; + size_t n = snprintf(NULL, 0, pattern, i); + char* id = (char*) alloca(n + 1); + snprintf(id, n + 1, pattern, i); + outputs[i] = ADM_dataset_create(id); + } + + ADM_job_requirements_t reqs = ADM_job_requirements_create( + inputs, NINPUTS, outputs, NOUTPUTS, NULL); + assert(reqs); + + ADM_storage_t pfs_storage; + + ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); + assert(ctx); + + ADM_storage_t st = ADM_storage_create("barbaz", ADM_STORAGE_GPFS, ctx); + assert(st); + + ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_pfs_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + fprintf(stdout, "ADM_register_pfs_storage() remote procedure completed " + "successfully\n"); + +cleanup: + ADM_server_destroy(server); + exit(exit_status); +} diff --git a/examples/c/ADM_remove_pfs_storage.c b/examples/c/ADM_remove_pfs_storage.c new file mode 100644 index 00000000..cf88f7ea --- /dev/null +++ b/examples/c/ADM_remove_pfs_storage.c @@ -0,0 +1,81 @@ +/****************************************************************************** + * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain + * + * This software was partially supported by the EuroHPC-funded project ADMIRE + * (Project ID: 956748, https://www.admire-eurohpc.eu). + * + * This file is part of scord. + * + * scord is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * scord is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with scord. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include +#include +#include + +#define NINPUTS 10 +#define NOUTPUTS 5 + +int +main(int argc, char* argv[]) { + + if(argc != 2) { + fprintf(stderr, "ERROR: no server address provided\n"); + fprintf(stderr, "Usage: ADM_remove_pfs_storage \n"); + exit(EXIT_FAILURE); + } + + int exit_status = EXIT_SUCCESS; + ADM_server_t server = ADM_server_create("tcp", argv[1]); + + ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); + assert(ctx); + + ADM_storage_t st = ADM_storage_create("barbaz", ADM_STORAGE_GPFS, ctx); + assert(st); + + ADM_storage_t pfs_storage; + ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_pfs_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + fprintf(stdout, "ADM_register_pfs_storage() remote procedure completed " + "successfully\n"); + + ret = ADM_remove_pfs_storage(server, pfs_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_remove_pfs_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + fprintf(stdout, "ADM_remove_pfs_storage() remote procedure completed " + "successfully\n"); + +cleanup: + ADM_server_destroy(server); + exit(exit_status); +} diff --git a/examples/c/ADM_update_pfs_storage.c b/examples/c/ADM_update_pfs_storage.c new file mode 100644 index 00000000..42520651 --- /dev/null +++ b/examples/c/ADM_update_pfs_storage.c @@ -0,0 +1,81 @@ +/****************************************************************************** + * Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain + * + * This software was partially supported by the EuroHPC-funded project ADMIRE + * (Project ID: 956748, https://www.admire-eurohpc.eu). + * + * This file is part of scord. + * + * scord is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * scord is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with scord. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + *****************************************************************************/ + +#include +#include +#include +#include + +#define NINPUTS 10 +#define NOUTPUTS 5 + +int +main(int argc, char* argv[]) { + + if(argc != 2) { + fprintf(stderr, "ERROR: no server address provided\n"); + fprintf(stderr, "Usage: ADM_update_pfs_storage \n"); + exit(EXIT_FAILURE); + } + + int exit_status = EXIT_SUCCESS; + ADM_server_t server = ADM_server_create("tcp", argv[1]); + + ADM_pfs_context_t ctx = ADM_pfs_context_create("/gpfs"); + assert(ctx); + + ADM_storage_t st = ADM_storage_create("barbaz", ADM_STORAGE_GPFS, ctx); + assert(st); + + ADM_storage_t pfs_storage; + ADM_return_t ret = ADM_register_pfs_storage(server, ctx, &pfs_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_register_pfs_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + fprintf(stdout, "ADM_register_pfs_storage() remote procedure completed " + "successfully\n"); + + ret = ADM_update_pfs_storage(server, ctx, pfs_storage); + + if(ret != ADM_SUCCESS) { + fprintf(stdout, + "ADM_update_pfs_storage() remote procedure not completed " + "successfully\n"); + exit_status = EXIT_FAILURE; + goto cleanup; + } + + fprintf(stdout, "ADM_update_pfs_storage() remote procedure completed " + "successfully\n"); + +cleanup: + ADM_server_destroy(server); + exit(exit_status); +} -- GitLab From 6ba826d058415294f99e33b69f9953a61c3e2025 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Tue, 6 Sep 2022 10:41:06 +0200 Subject: [PATCH 2/2] Update and enable CXX tests for ADM_*_pfs_storage RPCs --- examples/c/CMakeLists.txt | 7 ++++--- examples/cxx/ADM_register_pfs_storage.cpp | 2 +- examples/cxx/ADM_remove_pfs_storage.cpp | 2 +- examples/cxx/ADM_update_pfs_storage.cpp | 2 +- examples/cxx/CMakeLists.txt | 6 ++++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 3f683cc0..6d9d2faf 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -27,7 +27,8 @@ list(APPEND examples_c ADM_register_job ADM_cancel_transfer ADM_connect_data_ope ADM_get_statistics ADM_get_transfer_priority ADM_link_transfer_to_data_operation ADM_register_adhoc_storage ADM_remove_adhoc_storage ADM_remove_job ADM_set_dataset_information ADM_set_io_resources ADM_set_qos_constraints ADM_set_transfer_priority ADM_transfer_dataset - ADM_update_adhoc_storage ADM_update_job) + ADM_update_adhoc_storage ADM_update_job ADM_register_pfs_storage + ADM_update_pfs_storage ADM_remove_pfs_storage) # ADM_in_situ_ops ADM_in_transit_ops not implemented foreach(example IN LISTS examples_c) @@ -62,8 +63,8 @@ if(SCORD_BUILD_TESTS) add_test(ADM_register_adhoc_storage_c_test ADM_register_adhoc_storage ofi+tcp://127.0.0.1:52000) - # TODO: ADM_register_pfs_storage test is missing because is not working in cpp. - # Will be created when it works in cpp. + add_test(ADM_register_pfs_storage_c_test ADM_register_pfs_storage ofi+tcp://127.0.0.1:52000) + add_test(ADM_remove_adhoc_storage_c_test ADM_remove_adhoc_storage ofi+tcp://127.0.0.1:52000) add_test(ADM_remove_job_c_test ADM_remove_job ofi+tcp://127.0.0.1:52000) diff --git a/examples/cxx/ADM_register_pfs_storage.cpp b/examples/cxx/ADM_register_pfs_storage.cpp index 6b0c28db..5c6e2356 100644 --- a/examples/cxx/ADM_register_pfs_storage.cpp +++ b/examples/cxx/ADM_register_pfs_storage.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { if(argc != 2) { - fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "ERROR: no server address provided\n"); fmt::print(stderr, "Usage: ADM_register_pfs_storage \n"); exit(EXIT_FAILURE); diff --git a/examples/cxx/ADM_remove_pfs_storage.cpp b/examples/cxx/ADM_remove_pfs_storage.cpp index c4ae0588..b4e88de1 100644 --- a/examples/cxx/ADM_remove_pfs_storage.cpp +++ b/examples/cxx/ADM_remove_pfs_storage.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { if(argc != 2) { - fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "ERROR: no server address provided\n"); fmt::print(stderr, "Usage: ADM_remove_pfs_storage \n"); exit(EXIT_FAILURE); } diff --git a/examples/cxx/ADM_update_pfs_storage.cpp b/examples/cxx/ADM_update_pfs_storage.cpp index 5e3b5ab3..90451902 100644 --- a/examples/cxx/ADM_update_pfs_storage.cpp +++ b/examples/cxx/ADM_update_pfs_storage.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { if(argc != 2) { - fmt::print(stderr, "ERROR: no location provided\n"); + fmt::print(stderr, "ERROR: no server address provided\n"); fmt::print(stderr, "Usage: ADM_update_pfs_storage \n"); exit(EXIT_FAILURE); } diff --git a/examples/cxx/CMakeLists.txt b/examples/cxx/CMakeLists.txt index ec8d4409..e1ab0acb 100644 --- a/examples/cxx/CMakeLists.txt +++ b/examples/cxx/CMakeLists.txt @@ -69,12 +69,14 @@ if(SCORD_BUILD_TESTS) add_test(ADM_register_job_cxx_test ADM_register_job ofi+tcp://127.0.0.1:52000) - # TODO: add_test(ADM_register_pfs_storage_test ADM_register_pfs_storage ofi+tcp://127.0.0.1:52000) + add_test(ADM_register_pfs_storage_cxx_test ADM_register_pfs_storage ofi+tcp://127.0.0.1:52000) + add_test(ADM_remove_adhoc_storage_cxx_test ADM_remove_adhoc_storage ofi+tcp://127.0.0.1:52000) add_test(ADM_remove_job_cxx_test ADM_remove_job ofi+tcp://127.0.0.1:52000) - # TODO: add_test(ADM_remove_pfs_storage_test ADM_remove_pfs_storage ofi+tcp://127.0.0.1:52000 42) + add_test(ADM_remove_pfs_storage_cxx_test ADM_remove_pfs_storage ofi+tcp://127.0.0.1:52000) + add_test(ADM_set_dataset_information_cxx_test ADM_set_dataset_information ofi+tcp://127.0.0.1:52000) add_test(ADM_set_io_resources_cxx_test ADM_set_io_resources ofi+tcp://127.0.0.1:52000) -- GitLab