Commit 96be6fed authored by Ramon Nou's avatar Ramon Nou
Browse files

Merge branch 'amiranda/53-create-dedicated-server-in-ci-tests' into 'main'

Resolve "Create dedicated server in CI tests"

This MR adds a `scripts/runner.sh` helper script that allows starting and stopping the `scord` daemon from CMake. This in turn allows us to define CTest fixtures to startup and stop the server on demand, upon which RPC tests can depend on. Thus, the `scord` daemon will start automatically when running RPC tests, and will also stop automatically when the tests complete.

Closes #53

See merge request !38
parents 530b5377 3c875eca
Loading
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ build:
      - compiled/lib/
      - build/examples/
      - build/tests/
      - build/src/scord/scord
      - build/src/scord-ctl/scord-ctl
      # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
  cache:
    key: $CI_COMMIT_REF_SLUG
@@ -48,11 +50,8 @@ rpc:
    - export ASAN_OPTIONS=detect_odr_violation=0
    - export LSAN_OPTIONS=verbosity=1:log_threads=1:suppressions=${CI_PROJECT_DIR}/tests/LSanSuppress.supp
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${CI_PROJECT_DIR}/compiled/lib
    - compiled/bin/scord -f --force-console &
    - build/examples/cxx/ADM_ping ofi+tcp://127.0.0.1:52000
    - cd build/examples/
    - ctest -j$(nproc) --output-on-failure --output-junit rpc-report.xml
    - pkill -TERM scord
  artifacts:
    expire_in: 1 week
    paths:
+17 −0
Original line number Diff line number Diff line
@@ -22,5 +22,22 @@
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

if(SCORD_BUILD_TESTS)
  add_test(start_scord_daemon
    ${CMAKE_SOURCE_DIR}/scripts/runner.sh start scord.pid
           ${CMAKE_BINARY_DIR}/src/scord/scord -C -f
  )

  set_tests_properties(start_scord_daemon PROPERTIES FIXTURES_SETUP
    scord_daemon)

  add_test(stop_scord_daemon
    ${CMAKE_SOURCE_DIR}/scripts/runner.sh stop TERM scord.pid
    )

  set_tests_properties(stop_scord_daemon PROPERTIES FIXTURES_CLEANUP
    scord_daemon)
endif()

add_subdirectory(c)
add_subdirectory(cxx)

examples/c/ADM_ping.c

0 → 100644
+49 −0
Original line number Diff line number Diff line
/******************************************************************************
 * 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>

int
main(int argc, char* argv[]) {

    if(argc != 2) {
        fprintf(stderr, "ERROR: no location provided\n");
        fprintf(stderr, "Usage: ADM_ping <SERVER_ADDRESS>\n");
        exit(EXIT_FAILURE);
    }

    ADM_server_t server = ADM_server_create("tcp", argv[1]);

    ADM_return_t ret = ADM_ping(server);

    if(ret != ADM_SUCCESS) {
        fprintf(stdout, "ADM_ping() remote procedure not completed "
                        "successfully\n");
        exit(EXIT_FAILURE);
    }
    exit(EXIT_SUCCESS);
}
+27 −58
Original line number Diff line number Diff line
@@ -22,21 +22,33 @@
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

list(APPEND examples_c ADM_register_job ADM_cancel_transfer ADM_connect_data_operation ADM_define_data_operation
  ADM_deploy_adhoc_storage ADM_finalize_data_operation ADM_get_pending_transfers ADM_get_qos_constraints
  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_register_pfs_storage
  ADM_update_pfs_storage ADM_remove_pfs_storage)

# ADM_in_situ_ops ADM_in_transit_ops not implemented
list(APPEND examples_c
  # ping
  ADM_ping
  # job
  ADM_register_job ADM_update_job ADM_remove_job
  # adhoc storage
  ADM_register_adhoc_storage ADM_update_adhoc_storage ADM_remove_adhoc_storage
  ADM_deploy_adhoc_storage
  # pfs storage
  ADM_register_pfs_storage ADM_update_pfs_storage ADM_remove_pfs_storage
  # transfers
  ADM_transfer_dataset ADM_get_transfer_priority ADM_set_transfer_priority
  ADM_cancel_transfer ADM_get_pending_transfers
  # qos
  ADM_set_qos_constraints ADM_get_qos_constraints
  # data operations
  ADM_define_data_operation ADM_connect_data_operation
  ADM_finalize_data_operation ADM_link_transfer_to_data_operation
  # ADM_in_situ_ops ADM_in_transit_ops
  # misc
  ADM_get_statistics ADM_set_dataset_information ADM_set_io_resources
  )

add_library(c_examples_common STATIC)
target_sources(c_examples_common PUBLIC common.h PRIVATE common.c)
target_link_libraries(c_examples_common common::api::types)


foreach(example IN LISTS examples_c)
  add_executable(${example}_c)
  target_sources(${example}_c PRIVATE ${example}.c)
@@ -45,52 +57,9 @@ foreach(example IN LISTS examples_c)
endforeach()

if(SCORD_BUILD_TESTS)
  add_test(ADM_register_job_c_test ADM_register_job ofi+tcp://127.0.0.1:52000)

  add_test(ADM_cancel_transfer_c_test ADM_cancel_transfer ofi+tcp://127.0.0.1:52000)

  add_test(ADM_connect_data_operation_c_test ADM_connect_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_define_data_operation_c_test ADM_define_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_deploy_adhoc_storage_c_test ADM_deploy_adhoc_storage ofi+tcp://127.0.0.1:52000)

  add_test(ADM_finalize_data_operation_c_test ADM_finalize_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_pending_transfers_c_test ADM_get_pending_transfers ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_qos_constraints_c_test ADM_get_qos_constraints ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_statistics_c_test ADM_get_statistics ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_transfer_priority_c_test ADM_get_transfer_priority ofi+tcp://127.0.0.1:52000)

  add_test(ADM_link_transfer_to_data_operation_c_test ADM_link_transfer_to_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_register_adhoc_storage_c_test ADM_register_adhoc_storage ofi+tcp://127.0.0.1:52000)

  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)

  # TODO: ADM_remove_pfs_storage test is missing because is not working in cpp.
  # Will be created when it works in cpp.
  add_test(ADM_set_dataset_information_c_test ADM_set_dataset_information ofi+tcp://127.0.0.1:52000)

  add_test(ADM_set_io_resources_c_test ADM_set_io_resources ofi+tcp://127.0.0.1:52000)

  add_test(ADM_set_qos_constraints_c_test ADM_set_qos_constraints ofi+tcp://127.0.0.1:52000)

  add_test(ADM_set_transfer_priority_c_test ADM_set_transfer_priority ofi+tcp://127.0.0.1:52000)

  add_test(ADM_transfer_dataset_c_test ADM_transfer_dataset ofi+tcp://127.0.0.1:52000)

  add_test(ADM_update_adhoc_storage_c_test ADM_update_adhoc_storage ofi+tcp://127.0.0.1:52000)

  add_test(ADM_update_job_c_test ADM_update_job ofi+tcp://127.0.0.1:52000)

  # TODO: ADM_update_pfs_storage test is missing because is not working in cpp.
  # Will be created when it works in cpp.
  foreach(example IN LISTS examples_c)
    add_test(${example}_c_test ${example} ofi+tcp://${SCORD_BIND_ADDRESS}:${SCORD_BIND_PORT})
    set_tests_properties(${example}_c_test
      PROPERTIES FIXTURES_REQUIRED scord_daemon)
  endforeach()
endif()
+23 −56
Original line number Diff line number Diff line
@@ -23,19 +23,27 @@
################################################################################

list(APPEND examples_cxx
  # ping
  ADM_ping
  # job
  ADM_register_job ADM_update_job ADM_remove_job
  ADM_register_adhoc_storage ADM_update_adhoc_storage
  ADM_remove_adhoc_storage ADM_deploy_adhoc_storage
  ADM_register_pfs_storage ADM_update_pfs_storage
  ADM_remove_pfs_storage

  # adhoc storage
  ADM_register_adhoc_storage ADM_update_adhoc_storage ADM_remove_adhoc_storage
  ADM_deploy_adhoc_storage
  # pfs storage
  ADM_register_pfs_storage ADM_update_pfs_storage ADM_remove_pfs_storage
  # transfers
  ADM_transfer_dataset ADM_get_transfer_priority ADM_set_transfer_priority
  ADM_cancel_transfer ADM_get_pending_transfers
  # qos
  ADM_set_qos_constraints ADM_get_qos_constraints
  # data operations
  ADM_define_data_operation ADM_connect_data_operation
  ADM_finalize_data_operation ADM_link_transfer_to_data_operation
  # ADM_in_situ_ops ADM_in_transit_ops
  ADM_transfer_dataset
  ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority
  ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers
  ADM_set_qos_constraints ADM_get_qos_constraints ADM_define_data_operation ADM_connect_data_operation
  ADM_finalize_data_operation ADM_link_transfer_to_data_operation ADM_get_statistics)
  #misc
  ADM_get_statistics ADM_set_dataset_information ADM_set_io_resources
  )

add_library(cxx_examples_common STATIC)
target_sources(cxx_examples_common PUBLIC common.hpp PRIVATE common.cpp)
@@ -50,50 +58,9 @@ foreach(example IN LISTS examples_cxx)
endforeach()

if(SCORD_BUILD_TESTS)
  add_test(ADM_ping_test ADM_ping ofi+tcp://127.0.0.1:52000)

  add_test(ADM_cancel_transfer_cxx_test ADM_cancel_transfer ofi+tcp://127.0.0.1:52000)
  set_tests_properties(ADM_cancel_transfer_cxx_test PROPERTIES LABELS "ADM_cancel_transfer;cxx")

  add_test(ADM_connect_data_operation_cxx_test ADM_connect_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_define_data_operation_cxx_test ADM_define_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_deploy_adhoc_storage_cxx_test ADM_deploy_adhoc_storage ofi+tcp://127.0.0.1:52000)

  add_test(ADM_finalize_data_operation_cxx_test ADM_finalize_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_pending_transfers_cxx_test ADM_get_pending_transfers ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_qos_constraints_cxx_test ADM_get_qos_constraints ofi+tcp://127.0.0.1:52000)

  add_test(ADM_get_transfer_priority_cxx_test ADM_get_transfer_priority ofi+tcp://127.0.0.1:52000)

  add_test(ADM_link_transfer_to_data_operation_cxx_test ADM_link_transfer_to_data_operation ofi+tcp://127.0.0.1:52000)

  add_test(ADM_register_job_cxx_test ADM_register_job 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)

  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)

  add_test(ADM_set_qos_constraints_cxx_test ADM_set_qos_constraints ofi+tcp://127.0.0.1:52000)

  add_test(ADM_set_transfer_priority_cxx_test ADM_set_transfer_priority ofi+tcp://127.0.0.1:52000)

  add_test(ADM_transfer_dataset_cxx_test ADM_transfer_dataset ofi+tcp://127.0.0.1:52000)

  add_test(ADM_update_adhoc_storage_cxx_test ADM_update_adhoc_storage ofi+tcp://127.0.0.1:52000)

  add_test(ADM_update_job_cxx_test ADM_update_job ofi+tcp://127.0.0.1:52000)

  # TODO: add_test(ADM_update_pfs_storage_cxx_test ADM_update_pfs_storage ofi+tcp://127.0.0.1:52000 42)
  foreach(example IN LISTS examples_cxx)
    add_test(${example}_cxx_test ${example} ofi+tcp://${SCORD_BIND_ADDRESS}:${SCORD_BIND_PORT})
    set_tests_properties(${example}_cxx_test
      PROPERTIES FIXTURES_REQUIRED scord_daemon)
  endforeach()
endif()
Loading