diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b918d4..6e032f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,8 +62,11 @@ jobs: - name: Test run after install if: matrix.make == 'test-release' - run: | - ./local_installation/bin/pg_service_template --config=./local_installation/etc/pg_service_template/static_config.yaml & + run: >- + ./local_installation/bin/pg_service_template + --config=./local_installation/etc/pg_service_template/static_config.yaml + --config_vars=./local_installation/etc/pg_service_template/config_vars.yaml + & - name: Check work run service if: matrix.make == 'test-release' diff --git a/.gitignore b/.gitignore index 62d15c4..0810547 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ compile_commands.json .cores/ cmake-build-* Testing/ -configs/static_config.yaml +configs/config_vars.yaml +configs/config_vars.docker.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index 426b684..cbc101b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,26 +30,40 @@ add_google_tests(${PROJECT_NAME}_unittest) # Benchmarks add_executable(${PROJECT_NAME}_benchmark - src/hello_benchmark.cpp + src/hello_benchmark.cpp ) target_link_libraries(${PROJECT_NAME}_benchmark PRIVATE ${PROJECT_NAME}_objs userver-ubench) add_google_benchmark_tests(${PROJECT_NAME}_benchmark) + # Functional Tests -add_subdirectory(tests) +include(UserverTestsuite) + +userver_testsuite_add_simple( + REQUIREMENTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/requirements.txt" +) + +# Install if(DEFINED ENV{PREFIX}) - message(STATUS "Set install prefix: $ENV{PREFIX}") - file(TO_CMAKE_PATH "$ENV{PREFIX}" PREFIX_PATH) - set(CMAKE_INSTALL_PREFIX ${PREFIX_PATH}) + message(STATUS "Set install prefix: $ENV{PREFIX}") + file(TO_CMAKE_PATH "$ENV{PREFIX}" PREFIX_PATH) + set(CMAKE_INSTALL_PREFIX ${PREFIX_PATH}) endif() -set(CONFIG_VAR_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/config_vars.yaml) -set(CONFIG_FALLBACK_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/dynamic_config_fallback.json) +set(CONFIG_FALLBACK_PATH + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/dynamic_config_fallback.json") -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configs/static_config.yaml.in ${CMAKE_CURRENT_SOURCE_DIR}/configs/static_config.yaml) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/configs/config_vars.template.yaml" + "${CMAKE_CURRENT_SOURCE_DIR}/configs/config_vars.yaml" +) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/configs/config_vars.docker.template.yaml" + "${CMAKE_CURRENT_SOURCE_DIR}/configs/config_vars.docker.yaml" +) -FILE(GLOB CONFIGS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.yaml ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.json) +file(GLOB CONFIGS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.yaml ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.json) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PROJECT_NAME}) install(FILES ${CONFIGS_FILES} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME} COMPONENT ${PROJECT_NAME}) diff --git a/Makefile b/Makefile index b560250..fb857d4 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,8 @@ clean-debug clean-release: clean-%: .PHONY: dist-clean dist-clean: @rm -rf build_* - @rm -f ./configs/static_config.yaml + @rm -f ./configs/config_vars.docker.yaml + @rm -f ./configs/config_vars.yaml @rm -rf tests/__pycache__/ @rm -rf tests/.pytest_cache/ diff --git a/configs/config_vars.docker.yaml b/configs/config_vars.docker.template.yaml similarity index 72% rename from configs/config_vars.docker.yaml rename to configs/config_vars.docker.template.yaml index fa4ecb0..c61c239 100644 --- a/configs/config_vars.docker.yaml +++ b/configs/config_vars.docker.template.yaml @@ -2,8 +2,10 @@ worker-threads: 4 worker-fs-threads: 2 logger-level: debug -is_testing: false +is-testing: false server-port: 8080 dbconnection: 'postgresql://user:password@service-postgres:5432/pg_service_template_db_1' + +config-fallback-path: @CONFIG_FALLBACK_PATH@ diff --git a/configs/config_vars.yaml b/configs/config_vars.template.yaml similarity index 74% rename from configs/config_vars.yaml rename to configs/config_vars.template.yaml index 484f3e9..09bedd0 100644 --- a/configs/config_vars.yaml +++ b/configs/config_vars.template.yaml @@ -2,8 +2,10 @@ worker-threads: 4 worker-fs-threads: 2 logger-level: debug -is_testing: false +is-testing: false server-port: 8080 dbconnection: 'postgresql://pg_service_template_user:password@localhost:5432/pg_service_template_db_1' + +config-fallback-path: @CONFIG_FALLBACK_PATH@ diff --git a/configs/config_vars_testing.yaml b/configs/config_vars.testing.yaml similarity index 85% rename from configs/config_vars_testing.yaml rename to configs/config_vars.testing.yaml index a0688ab..12bbeae 100644 --- a/configs/config_vars_testing.yaml +++ b/configs/config_vars.testing.yaml @@ -2,9 +2,7 @@ worker-threads: 4 worker-fs-threads: 2 logger-level: debug -is_testing: true - -server-port: 8080 +is-testing: true # pg_service_template_db_1 is the service name + _ + filename of the db_1.sql dbconnection: 'postgresql://testsuite@localhost:15433/pg_service_template_db_1' diff --git a/configs/static_config.yaml.in b/configs/static_config.yaml similarity index 94% rename from configs/static_config.yaml.in rename to configs/static_config.yaml index 1591b33..b8ec6f4 100644 --- a/configs/static_config.yaml.in +++ b/configs/static_config.yaml @@ -1,7 +1,5 @@ # yaml -config_vars: @CONFIG_VAR_PATH@ - components_manager: coro_pool: initial_size: 500 # Preallocate 500 coroutines at startup. @@ -38,15 +36,15 @@ components_manager: dynamic-config: # Dynamic config storage options, do nothing fs-cache-path: '' dynamic-config-fallbacks: # Load options from file and push them into the dynamic config storage. - fallback-path: @CONFIG_FALLBACK_PATH@ + fallback-path: $config-fallback-path testsuite-support: {} http-client: - load-enabled: $is_testing + load-enabled: $is-testing fs-task-processor: fs-task-processor tests-control: - load-enabled: $is_testing + load-enabled: $is-testing path: /tests/{action} method: POST task_processor: main-task-processor diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index f950442..0000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include(UserverTestsuite) - -set(CONFIG_VARS_PATH "${CMAKE_SOURCE_DIR}/configs/config_vars_testing.yaml") -if (EXISTS "${CONFIG_VARS_PATH}") - set(PYTEST_ARGS_CONFIG_VARS "--service-config-vars=${CONFIG_VARS_PATH}") -else() - set(PYTEST_ARGS_CONFIG_VARS "") -endif() - -userver_testsuite_add( - SERVICE_TARGET pg_service_template - REQUIREMENTS ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - PYTEST_ARGS - --service-config=${CMAKE_SOURCE_DIR}/configs/static_config.yaml - --service-binary=${CMAKE_BINARY_DIR}/pg_service_template - --config-fallback=${CMAKE_SOURCE_DIR}/configs/dynamic_config_fallback.json - ${PYTEST_ARGS_CONFIG_VARS} -) diff --git a/third_party/userver b/third_party/userver index 1261055..662e1a1 160000 --- a/third_party/userver +++ b/third_party/userver @@ -1 +1 @@ -Subproject commit 1261055101b13896fa3e732be234aa2d431c48ff +Subproject commit 662e1a1c26242a141ab34cce01cd303e7b740be3