Skip to content
Snippets Groups Projects
Verified Commit e762ae7c authored by Alberto Miranda's avatar Alberto Miranda :hotsprings:
Browse files

Add C tests for ADM_*_pfs_storage RPCs

parent eaaf3027
No related branches found
No related tags found
1 merge request!33Resolve "Tests for `ADM_register_pfs_storage` and related RPCs are not run"
/******************************************************************************
* 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 <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <admire.h>
#include <assert.h>
#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 <SERVER_ADDRESS>\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);
}
/******************************************************************************
* 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 <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <admire.h>
#include <assert.h>
#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 <SERVER_ADDRESS>\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);
}
/******************************************************************************
* 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 <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <admire.h>
#include <assert.h>
#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 <SERVER_ADDRESS>\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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment