From f096fb5880bac9fe05781d481e85444945e2c350 Mon Sep 17 00:00:00 2001 From: Romy <35330373+romayalon@users.noreply.github.com> Date: Thu, 22 May 2025 15:29:05 +0300 Subject: [PATCH] CI | Mint Integration with NooBaa Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com> --- .github/workflows/mint-nc-tests.yaml | 41 +++++++ .github/workflows/mint-tests.yaml | 41 +++++++ .github/workflows/run-pr-tests.yaml | 8 ++ Makefile | 69 ++++++++++- docs/CI & Tests/Mint.md | 107 ++++++++++++++++++ src/endpoint/s3/s3_errors.js | 2 +- .../warp_utils.js => external_tests_utils.js} | 60 +++++----- src/test/system_tests/mint/configure_mint.js | 31 +++++ src/test/system_tests/mint/mint_constants.js | 47 ++++++++ .../mint/run_mint_on_test_container.sh | 53 +++++++++ .../mint/run_nc_mint_on_test_container.sh | 57 ++++++++++ src/test/system_tests/warp/configure_warp.js | 9 +- src/test/system_tests/warp/run_warp.js | 4 +- 13 files changed, 488 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/mint-nc-tests.yaml create mode 100644 .github/workflows/mint-tests.yaml create mode 100644 docs/CI & Tests/Mint.md rename src/test/system_tests/{warp/warp_utils.js => external_tests_utils.js} (65%) create mode 100644 src/test/system_tests/mint/configure_mint.js create mode 100644 src/test/system_tests/mint/mint_constants.js create mode 100644 src/test/system_tests/mint/run_mint_on_test_container.sh create mode 100644 src/test/system_tests/mint/run_nc_mint_on_test_container.sh diff --git a/.github/workflows/mint-nc-tests.yaml b/.github/workflows/mint-nc-tests.yaml new file mode 100644 index 0000000000..cca56820de --- /dev/null +++ b/.github/workflows/mint-nc-tests.yaml @@ -0,0 +1,41 @@ + +name: Mint NC Tests +on: [workflow_call] + +jobs: + mint-nc-tests: + name: Mint NC Tests + runs-on: ubuntu-latest + timeout-minutes: 90 + permissions: + actions: read # download-artifact + contents: read # required for actions/checkout + steps: + - name: Checkout noobaa-core + uses: actions/checkout@v4 + with: + repository: 'noobaa/noobaa-core' + path: 'noobaa-core' + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: noobaa-tester + path: /tmp + + - name: Load image + run: docker load --input /tmp/noobaa-tester.tar + + - name: Create Mint logs directory + run: | + set -x + cd ./noobaa-core + mkdir -p logs/mint-nc-test-logs + chmod 777 logs/mint-nc-test-logs + + - name: Run NC Mint tests + run: | + set -x + cd ./noobaa-core + make test-nc-mint -o tester + diff --git a/.github/workflows/mint-tests.yaml b/.github/workflows/mint-tests.yaml new file mode 100644 index 0000000000..20933c8009 --- /dev/null +++ b/.github/workflows/mint-tests.yaml @@ -0,0 +1,41 @@ +name: Mint Tests +on: [workflow_call] + +jobs: + mint-tests: + name: Mint Tests + runs-on: ubuntu-latest + timeout-minutes: 90 + permissions: + actions: read # download-artifact + contents: read # required for actions/checkout + steps: + - name: Checkout noobaa-core + uses: actions/checkout@v4 + with: + repository: 'noobaa/noobaa-core' + path: 'noobaa-core' + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: noobaa-tester + path: /tmp + + - name: Load image + run: docker load --input /tmp/noobaa-tester.tar + + - name: Create Mint logs directory + run: | + set -x + cd ./noobaa-core + mkdir -p logs/mint-test-logs + chmod 777 logs/mint-test-logs + + - name: Run Mint tests + run: | + set -x + cd ./noobaa-core + make test-mint -o tester + + diff --git a/.github/workflows/run-pr-tests.yaml b/.github/workflows/run-pr-tests.yaml index 7fed7f4aea..6bee3812e9 100644 --- a/.github/workflows/run-pr-tests.yaml +++ b/.github/workflows/run-pr-tests.yaml @@ -41,6 +41,14 @@ jobs: needs: build-noobaa-image uses: ./.github/workflows/warp-nc-tests.yaml + mint-tests: + needs: build-noobaa-image + uses: ./.github/workflows/mint-tests.yaml + + mint-nc-tests: + needs: build-noobaa-image + uses: ./.github/workflows/mint-nc-tests.yaml + build-noobaa-image: name: Build Noobaa Image runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 6a38c8146f..72675f004f 100644 --- a/Makefile +++ b/Makefile @@ -81,10 +81,17 @@ ifdef testname endif endif +###################### +# S3SELECT VARIABLES # +###################### + BUILD_S3SELECT?=1 BUILD_S3SELECT_PARQUET?=0 -## RPM VARIABLES +################# +# RPM VARIABLES # +################# + DATE := $(shell date +'%Y%m%d') NOOBAA_PKG_VERSION := $(shell jq -r '.version' < ./package.json) RPM_BASE_VERSION := noobaa-core-$(NOOBAA_PKG_VERSION)-${DATE} @@ -96,6 +103,14 @@ endif RPM_FULL_PATH := $(RPM_BASE_VERSION).el${CENTOS_VER}.$(ARCH_SUFFIX).rpm install_rpm_and_deps_command := dnf install -y make && rpm -i $(RPM_FULL_PATH) && systemctl enable noobaa --now && systemctl status noobaa && systemctl stop noobaa +################## +# MINT VARIABLES # +################## + +MINT_MOCK_ACCESS_KEY="aaaaaaaaaaaaaEXAMPLE" +MINT_MOCK_SECRET_KEY="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaEXAMPLE" +MINT_NOOBAA_HTTP_ENDPOINT_PORT=6001 + ############### # BUILD LOCAL # ############### @@ -353,6 +368,42 @@ test-nc-warp: tester $(CONTAINER_ENGINE) run $(CPUSET) --privileged --user root --name noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) --env "SUPPRESS_LOGS=$(SUPPRESS_LOGS)" -v $(PWD)/logs:/logs $(TESTER_TAG) "./src/test/system_tests/warp/run_nc_warp_on_test_container.sh" .PHONY: test-nc-warp +test-mint: tester + @echo "\033[1;34mRunning mint tests with Postgres.\033[0m" + @$(call create_docker_network) + @$(call run_postgres) + @echo "\033[1;34mRunning mint tests\033[0m" + $(CONTAINER_ENGINE) run $(CPUSET) --name noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) -dit --network noobaa-net --env "SUPPRESS_LOGS=$(SUPPRESS_LOGS)" --env "POSTGRES_HOST=coretest-postgres-$(GIT_COMMIT)-$(NAME_POSTFIX)" --env "POSTGRES_USER=noobaa" --env "DB_TYPE=postgres" --env "POSTGRES_DBNAME=coretest" -v $(PWD)/logs/mint-test-logs/:/logs $(TESTER_TAG) bash -c "./src/test/system_tests/mint/run_mint_on_test_container.sh & tail -f /dev/null" + sleep 180 + $(CONTAINER_ENGINE) run --name mint-$(GIT_COMMIT)-$(NAME_POSTFIX) --network noobaa-net -v $(PWD)/logs/mint-test-logs/:/mint/log --env SERVER_ENDPOINT=noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX):$(MINT_NOOBAA_HTTP_ENDPOINT_PORT) --env ACCESS_KEY=$(MINT_MOCK_ACCESS_KEY) --env SECRET_KEY=$(MINT_MOCK_SECRET_KEY) --env ENABLE_HTTPS=0 minio/mint minio-go s3cmd + @echo "\033[1;34mPrinting noobaa configuration and logs\033[0m" + $(CONTAINER_ENGINE) logs noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) + @echo "\033[1;34mPrinting mint results file\033[0m" + cat $(PWD)/logs/mint-test-logs/log.json + @$(call disconnect_container_from_noobaa_network, mint-$(GIT_COMMIT)-$(NAME_POSTFIX)) + $(CONTAINER_ENGINE) rm mint-$(GIT_COMMIT)-$(NAME_POSTFIX) + @$(call stop_noobaa) + @$(call stop_postgres) + @$(call remove_docker_network) +.PHONY: test-mint + + +test-nc-mint: tester + @echo "\033[1;34mRunning mint tests on NC environment\033[0m" + @$(call create_docker_network) + $(CONTAINER_ENGINE) run $(CPUSET) --name noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) -dit --privileged --user root --env "SUPPRESS_LOGS=$(SUPPRESS_LOGS)" --network noobaa-net -v $(PWD)/logs/mint-nc-test-logs/:/logs $(TESTER_TAG) bash -c "./src/test/system_tests/mint/run_nc_mint_on_test_container.sh; tail -f /dev/null" + sleep 15 + $(CONTAINER_ENGINE) run --name mint-$(GIT_COMMIT)-$(NAME_POSTFIX) --network noobaa-net -v $(PWD)/logs/mint-nc-test-logs/:/mint/log --env RUN_ON_FAIL=0 --env SERVER_ENDPOINT=noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX):$(MINT_NOOBAA_HTTP_ENDPOINT_PORT) --env ACCESS_KEY=$(MINT_MOCK_ACCESS_KEY) --env SECRET_KEY=$(MINT_MOCK_SECRET_KEY) --env ENABLE_HTTPS=0 minio/mint minio-go s3cmd + @echo "\033[1;34mPrinting noobaa configuration and logs\033[0m" + $(CONTAINER_ENGINE) logs noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) + @echo "\033[1;34mPrinting mint results file\033[0m" + cat $(PWD)/logs/mint-nc-test-logs/log.json + @$(call disconnect_container_from_noobaa_network, mint-$(GIT_COMMIT)-$(NAME_POSTFIX)) + $(CONTAINER_ENGINE) rm mint-$(GIT_COMMIT)-$(NAME_POSTFIX) + @$(call stop_noobaa) + @$(call remove_docker_network) +.PHONY: test-nc-mint + test-nsfs-cephs3: tester @echo "\033[1;34mRunning Ceph S3 tests on NSFS Standalone platform\033[0m" $(CONTAINER_ENGINE) run $(CPUSET) --privileged --user root --name noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) --env "SUPPRESS_LOGS=$(SUPPRESS_LOGS)" -v $(PWD)/logs:/logs $(TESTER_TAG) "./src/test/system_tests/ceph_s3_tests/run_ceph_nsfs_test_on_test_container.sh" @@ -413,7 +464,7 @@ clean: define stop_noobaa @echo "\033[1;34mStopping/removing test container\033[0m" - $(CONTAINER_ENGINE) network disconnect noobaa-net noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) + $(call disconnect_container_from_noobaa_network, noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX)) $(CONTAINER_ENGINE) stop noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) $(CONTAINER_ENGINE) rm noobaa_$(GIT_COMMIT)_$(NAME_POSTFIX) @echo "\033[1;32mRemoving test container done.\033[0m" @@ -435,6 +486,12 @@ define remove_docker_network @echo "\033[1;32mRemove docker network done.\033[0m" endef +define disconnect_container_from_noobaa_network + echo "\033[1;34mDisconnect container $(1) from noobaa network\033[0m"; \ + $(CONTAINER_ENGINE) network disconnect noobaa-net $(1); \ + echo "\033[1;34mDisconnect container $(1) from noobaa network done.\033[0m" +endef + ######### # MONGO # ######### @@ -447,7 +504,7 @@ endef define stop_mongo @echo "\033[1;34mStopping/removing Mongo container\033[0m" - $(CONTAINER_ENGINE) network disconnect noobaa-net coretest-mongo-$(GIT_COMMIT)-$(NAME_POSTFIX) + $(call disconnect_container_from_noobaa_network, coretest-mongo-$(GIT_COMMIT)-$(NAME_POSTFIX)) $(CONTAINER_ENGINE) stop coretest-mongo-$(GIT_COMMIT)-$(NAME_POSTFIX) $(CONTAINER_ENGINE) rm coretest-mongo-$(GIT_COMMIT)-$(NAME_POSTFIX) @echo "\033[1;32mStop mongo done.\033[0m" @@ -467,7 +524,7 @@ endef define stop_postgres @echo "\033[1;34mStopping/removing Postgres container\033[0m" - $(CONTAINER_ENGINE) network disconnect noobaa-net coretest-postgres-$(GIT_COMMIT)-$(NAME_POSTFIX) + $(call disconnect_container_from_noobaa_network, coretest-postgres-$(GIT_COMMIT)-$(NAME_POSTFIX)) $(CONTAINER_ENGINE) stop coretest-postgres-$(GIT_COMMIT)-$(NAME_POSTFIX) $(CONTAINER_ENGINE) rm coretest-postgres-$(GIT_COMMIT)-$(NAME_POSTFIX) @echo "\033[1;32mStop postgres done.\033[0m" @@ -487,7 +544,7 @@ endef define stop_external_postgres @echo "\033[1;34mStopping/removing Postgres container\033[0m" - $(CONTAINER_ENGINE) network disconnect noobaa-net ssl-pg-$(GIT_COMMIT)-$(NAME_POSTFIX) + $(call disconnect_container_from_noobaa_network, ssl-pg-$(GIT_COMMIT)-$(NAME_POSTFIX)) $(CONTAINER_ENGINE) stop ssl-pg-$(GIT_COMMIT)-$(NAME_POSTFIX) $(CONTAINER_ENGINE) rm ssl-pg-$(GIT_COMMIT)-$(NAME_POSTFIX) @echo "\033[1;32mStop postgres done.\033[0m" @@ -518,7 +575,7 @@ define stop_blob_mock @echo "\033[1;34mStopping blob mock server if RUN_BLOB_MOCK=$(RUN_BLOB_MOCK) is true.\033[0m" @ if [ $(RUN_BLOB_MOCK) = true ]; then \ echo "\033[1;34mStopping tests with Blob mock.\033[0m"; \ - $(CONTAINER_ENGINE) network disconnect noobaa-net blob-mock-$(GIT_COMMIT)-$(NAME_POSTFIX); \ + $(call disconnect_container_from_noobaa_network, blob-mock-$(GIT_COMMIT)-$(NAME_POSTFIX)); \ $(CONTAINER_ENGINE) stop blob-mock-$(GIT_COMMIT)-$(NAME_POSTFIX); \ $(CONTAINER_ENGINE) rm blob-mock-$(GIT_COMMIT)-$(NAME_POSTFIX); \ fi diff --git a/docs/CI & Tests/Mint.md b/docs/CI & Tests/Mint.md new file mode 100644 index 0000000000..fb4b5c0dbf --- /dev/null +++ b/docs/CI & Tests/Mint.md @@ -0,0 +1,107 @@ +# Mint Github Action, Tests and Tool + +1. [Introduction](#introduction) +2. [Mint GitHub actions](#mint-github-actions) +3. [Mint Makefile Targets](#mint-makefile-targets) +4. [Manual Mint Installation](#manual-mint-installation) + + + +## Introduction + +[Mint](https://github.com/minio/mint) is a testing framework for S3-compatible object storage systems, NooBaa CI runs Mint as correctness/benchmarking and stress tests for the NooBaa system on both containerized and Non Containerized flavors. +Following are the SDKs/tools used in correctness tests. + +- awscli +- aws-sdk-go +- aws-sdk-java +- aws-sdk-java-v2 +- aws-sdk-php +- aws-sdk-ruby +- healthcheck +- mc +- minio-go +- minio-java +- minio-js +- minio-py +- s3cmd +- s3select +- versioning + +## Mint GitHub actions + +NooBaa CI contains 2 Github actions that build, configure and run Mint. These Github actions run automatically on every PR and on every push, and can run by workflow dispatch manually. +* [Mint Tests](../../.github/workflows/mint-tests.yaml) - Based on NooBaa Tester image, runs Mint on standard NooBaa (db configuration). +* [Mint NC Tests](../../.github/workflows/mint-nc-tests.yaml) - Based on NooBaa Tester image, runs Mint on non-containerized NooBaa (ConfigFS configuration). + +Our next goal is to add longer Mint runs as part of NooBaa's nightly CI process. + +## Mint Makefile Targets + +One can run Mint tests on NooBaa using Mint Makefile targets - +* `make test-mint` - Based on NooBaa Tester image, runs Mint on standard NooBaa (db configuration). +* `make test-nc-mint` - Based on NooBaa Tester image, runs Mint on non-containerized NooBaa (ConfigFS configuration). + +The above makefile targets, build NooBaa tester image, and later deploy NooBaa (DB/ConfigFS deployments), create default account and runs the supported sdks on Mint per the deployment type. + +Currently, the supported mint test frameworks are: +1. s3cmd +2. minio-go + +## Manual Mint Installation + +NC deployment - +1. Tab 1 - Install NooBaa +2. Tab 2 - Create a NooBaa account. +2. Tab 2 - Run Mint pointing to NooBaa endpoint - +``` +docker run -e SERVER_ENDPOINT=: -e ACCESS_KEY= -e SECRET_KEY= -e ENABLE_HTTPS=0 minio/mint +``` + +Developer notes - + + +To manually run a MinIO Mint container that connects to a noobaa-tester container, ensure both containers are on the same Docker network (noobaa-net). + + +If the noobaa-tester is already connected to noobaa-net, your Mint run command should look like this: +``` +docker run -e SERVER_ENDPOINT=: -e ACCESS_KEY= -e SECRET_KEY= -e ENABLE_HTTPS=0 --network noobaa-net minio/mint +``` + +Replace with the specific SDK or tool you want to test (e.g., aws-sdk-java, minio-go, s3cmd, etc.). + +## Debugging Mint on NooBaa locally - +Running `make test-mint` will generate the following debug log files - + +```bash +noobaa-core % tree logs/mint-test-logs +logs/mint-test-logs +├── log.json // contains the Mint run results +├── minio-go +│   └── error.log // contains errors coming from minio-go run +├── mint-test-logs +│   ├── backingstore1.log // contains noobaa backingstore logs +│   ├── bg.log // contains noobaa BG workers logs +│   ├── hosted_agents.log // contains noobaa hosted agents logs +│   ├── s3.log // contains noobaa endpoint logs +│   └── web.log // contains noobaa webserver logs +└── s3cmd + └── error.log // contains errors coming from s3-cmd run + +``` + +Running `make test-nc-mint` will generate the following debug log files - + +```bash +noobaa-core % tree /mint-nc-test-logs +logs/mint-nc-test-logs + ├── log.json // contains the Mint run results + ├── minio-go + │   └── error.log // contains errors coming from minio-go run + ├── mint-nc-test-logs + │   └── nsfs.log // contains NC noobaa endpoint logs + └── s3cmd + └── error.log // contains errors coming from s3-cmd run + +``` diff --git a/src/endpoint/s3/s3_errors.js b/src/endpoint/s3/s3_errors.js index 9ecccfcf68..3ed71bdd9c 100644 --- a/src/endpoint/s3/s3_errors.js +++ b/src/endpoint/s3/s3_errors.js @@ -332,7 +332,7 @@ S3Error.NoLoggingStatusForKey = Object.freeze({ }); S3Error.NoSuchBucket = Object.freeze({ code: 'NoSuchBucket', - message: 'The specified bucket does not exist.', + message: 'The specified bucket does not exist', http_code: 404, }); S3Error.NoSuchKey = Object.freeze({ diff --git a/src/test/system_tests/warp/warp_utils.js b/src/test/system_tests/external_tests_utils.js similarity index 65% rename from src/test/system_tests/warp/warp_utils.js rename to src/test/system_tests/external_tests_utils.js index 30a01c21b5..676eea8c3d 100644 --- a/src/test/system_tests/warp/warp_utils.js +++ b/src/test/system_tests/external_tests_utils.js @@ -1,10 +1,9 @@ /* Copyright (C) 2016 NooBaa */ "use strict"; -const api = require('../../../api'); -const { WARP_TEST } = require('./warp_constants'); -const SensitiveString = require('../../../util/sensitive_string'); -const { get_account, create_account, create_bucket } = require('../nc_test_utils'); +const api = require('../../api'); +const SensitiveString = require('../../util/sensitive_string'); +const { get_account, create_account, create_bucket } = require('./nc_test_utils'); /** * get_global_rpc_client returns a global RPC client. @@ -55,48 +54,48 @@ async function get_account_by_name(account_name) { } /** - * get_warp_access_keys returns the access keys of the warp account. + * get_account_access_keys returns the access keys of an account. * @param {String} account_name * @returns {Promise<{ access_key: String, secret_key: String }>} */ -async function get_warp_access_keys(account_name) { - const warp_account = process.env.LOCAL_MD_SERVER === 'true' ? +async function get_account_access_keys(account_name) { + const account = is_containerized_deployment() ? await get_account_by_name(account_name) : await get_account(account_name); - const warp_access_keys = warp_account.access_keys[0]; - const access_key = new SensitiveString(warp_access_keys.access_key).unwrap(); - const secret_key = new SensitiveString(warp_access_keys.secret_key).unwrap(); + const access_keys = account.access_keys[0]; + const access_key = new SensitiveString(access_keys.access_key).unwrap(); + const secret_key = new SensitiveString(access_keys.secret_key).unwrap(); return { access_key, secret_key }; } /** - * create_warp_account creates a warp account. + * create_system_test_account creates an account to be used by system test per the deployment type. + * @param {Object} account_options - The options for the account. * @returns {Promise} */ -async function create_warp_account() { +async function create_system_test_account(account_options) { try { if (is_containerized_deployment()) { - await create_containerized_account(); + await create_containerized_account(account_options); } else { - const account_options = WARP_TEST.nc_warp_account_params; await create_account(account_options); } - console.info('WARP account created:', WARP_TEST.warp_account_params); + console.info('system test account created:', account_options); } catch (err) { - throw new Error(`Failed to create account ${err.message}`); + throw new Error(`Failed to create account for system tests ${err.message}`); } } /** - * create_warp_bucket creates a bucket in warp. + * create_system_test_bucket creates a bucket in warp. + * @param {Object} bucket_options - The options for the bucket. * @returns {Promise} */ -async function create_warp_bucket() { +async function create_system_test_bucket(account_options, bucket_options) { try { if (is_containerized_deployment()) { - await create_containerized_bucket(); + await create_containerized_bucket(account_options, bucket_options); } else { - const bucket_options = WARP_TEST.nc_warp_bucket_params; await create_bucket(bucket_options); } } catch (err) { @@ -108,29 +107,31 @@ async function create_warp_bucket() { * create_containerized_account creates a containerized account. * @returns {Promise} */ -async function create_containerized_account() { +async function create_containerized_account(account_options) { const global_rpc_client = await get_authenticated_global_rpc_client(); const system = await global_rpc_client.system.read_system(); // We are taking the first host pool, in normal k8s setup is default backing store const test_pool = system.pools.filter(p => p.resource_type === 'HOSTS')[0]; console.log(test_pool); await global_rpc_client.account.create_account({ - ...WARP_TEST.warp_account_params, + ...account_options, default_resource: test_pool.name }); } /** * create_containerized_bucket creates a bucket in containerized deployment. + * @param {Object} account_options - The options for the bucket owner account. + * @param {Object} bucket_options - The options for the bucket. * @returns {Promise} */ -async function create_containerized_bucket() { - const { email, password } = WARP_TEST.warp_account_params; +async function create_containerized_bucket(account_options, bucket_options) { + const { email, password } = account_options; const warp_account_rpc_client = await get_rpc_client_by_email_and_password(email, password); await warp_account_rpc_client.bucket.create_bucket({ - name: WARP_TEST.warp_bucket_params.name, + name: bucket_options.name, }); - console.info('WARP bucket created:', WARP_TEST.warp_bucket_params); + console.info('containerized bucket created:', bucket_options); } /** @@ -142,9 +143,10 @@ function is_containerized_deployment() { } // EXPORTS -exports.create_warp_bucket = create_warp_bucket; -exports.create_warp_account = create_warp_account; -exports.get_warp_access_keys = get_warp_access_keys; +exports.create_system_test_bucket = create_system_test_bucket; +exports.create_system_test_account = create_system_test_account; +exports.get_account_access_keys = get_account_access_keys; exports.get_authenticated_global_rpc_client = get_authenticated_global_rpc_client; exports.get_rpc_client_by_email_and_password = get_rpc_client_by_email_and_password; +exports.is_containerized_deployment = is_containerized_deployment; diff --git a/src/test/system_tests/mint/configure_mint.js b/src/test/system_tests/mint/configure_mint.js new file mode 100644 index 0000000000..c1719a87de --- /dev/null +++ b/src/test/system_tests/mint/configure_mint.js @@ -0,0 +1,31 @@ +/* Copyright (C) 2016 NooBaa */ +"use strict"; + +const dbg = require('../../../util/debug_module')(__filename); +dbg.set_process_name('test_mint_s3'); + +const { MINT_TEST } = require('./mint_constants'); +const { is_containerized_deployment, create_system_test_account } = require('../external_tests_utils.js'); + +async function main() { + try { + await mint_test_setup(); + } catch (err) { + console.error(`Mint Setup Failed: ${err}`); + process.exit(1); + } + process.exit(0); +} + +async function mint_test_setup() { + console.info('MINT TEST CONFIGURATION:', JSON.stringify(MINT_TEST)); + const is_containerized = is_containerized_deployment(); + const account_options = is_containerized ? MINT_TEST.mint_account_params : MINT_TEST.nc_mint_account_params; + await create_system_test_account(account_options); + console.info('MINT TEST SETUP DONE'); +} + +if (require.main === module) { + main(); +} + diff --git a/src/test/system_tests/mint/mint_constants.js b/src/test/system_tests/mint/mint_constants.js new file mode 100644 index 0000000000..62eecee32d --- /dev/null +++ b/src/test/system_tests/mint/mint_constants.js @@ -0,0 +1,47 @@ +/* Copyright (C) 2022 NooBaa */ +'use strict'; + +const SensitiveString = require('../../../util/sensitive_string'); + +const mint_account_name = 'mint_account'; + +// NC mint tests paths for bucket creation +const FS_ROOT_1 = '/tmp/nsfs_root1/'; +const FS_ROOT_2 = '/tmp/nsfs_root2/'; +const MINT_MOCK_ACCESS_KEY = 'aaaaaaaaaaaaaEXAMPLE'; +const MINT_MOCK_SECRET_KEY = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaEXAMPLE'; + +const MINT_TEST = { + s3_test_dir: 's3-tests/', + mint_logs_dir_path: '/logs/mint-test-logs', + mint_account_params: { + name: mint_account_name, + email: 'mint_account@noobaa.com', + has_login: true, + password: 'mint_pass123_example', + s3_access: true, + allow_bucket_creation: true, + access_keys: [{ + access_key: new SensitiveString(MINT_MOCK_ACCESS_KEY), + secret_key: new SensitiveString(MINT_MOCK_SECRET_KEY) + }] + }, + nc_mint_account_params: { + name: mint_account_name, + uid: 1000, + gid: 1000, + new_buckets_path: FS_ROOT_1, + access_key: MINT_MOCK_ACCESS_KEY, + secret_key: MINT_MOCK_SECRET_KEY + }, + nc_anonymous_account_params: { + anonymous: true, + uid: process.getuid(), + gid: process.getgid() + } +}; + +exports.MINT_TEST = MINT_TEST; +exports.FS_ROOT_1 = FS_ROOT_1; +exports.FS_ROOT_2 = FS_ROOT_2; + diff --git a/src/test/system_tests/mint/run_mint_on_test_container.sh b/src/test/system_tests/mint/run_mint_on_test_container.sh new file mode 100644 index 0000000000..229645e210 --- /dev/null +++ b/src/test/system_tests/mint/run_mint_on_test_container.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +export PS4='\e[36m+ ${FUNCNAME:-main}\e[0m@\e[32m${BASH_SOURCE}:\e[35m${LINENO} \e[0m' + +set -e + +# ==================================================================================== +# Set the environment variables +export email='admin@noobaa.io' +export password=123456789 + +export PORT=8080 +export SSL_PORT=5443 +export ENDPOINT_PORT=6001 +export ENDPOINT_SSL_PORT=6443 +export NOOBAA_MGMT_SERVICE_HOST=localhost +export NOOBAA_MGMT_SERVICE_PORT=${SSL_PORT} +export NOOBAA_MGMT_SERVICE_PROTO=wss +export S3_SERVICE_HOST=localhost + +export CREATE_SYS_NAME=noobaa +export CREATE_SYS_EMAIL=${email} +export CREATE_SYS_PASSWD=${password} +export JWT_SECRET=123456789 +export NOOBAA_ROOT_SECRET='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' +export LOCAL_MD_SERVER=true + +#The default max connections for postgres is 100. limit max clients to 10 per pool (per process). +export CONFIG_JS_POSTGRES_MD_MAX_CLIENTS=10 +export CONFIG_JS_POSTGRES_DEFAULT_MAX_CLIENTS=10 + +export POSTGRES_HOST=${POSTGRES_HOST:-localhost} +export MGMT_ADDR=wss://${NOOBAA_MGMT_SERVICE_HOST:-localhost}:${NOOBAA_MGMT_SERVICE_PORT:-5443} +export BG_ADDR=wss://localhost:5445 +export HOSTED_AGENTS_ADDR=wss://localhost:5446 +export CEPH_TEST_LOGS_DIR=/logs/mint-test-logs + +# ==================================================================================== + +# Create the logs directory +mkdir -p ${CEPH_TEST_LOGS_DIR} + +# ==================================================================================== + +# Deploy standalone NooBaa on the test container +./src/deploy/NVA_build/standalone_deploy.sh + +# ==================================================================================== + +cd /root/node_modules/noobaa-core/ + +# Configure the mint test +node ./src/test/system_tests/mint/configure_mint.js diff --git a/src/test/system_tests/mint/run_nc_mint_on_test_container.sh b/src/test/system_tests/mint/run_nc_mint_on_test_container.sh new file mode 100644 index 0000000000..9aa09fb9ce --- /dev/null +++ b/src/test/system_tests/mint/run_nc_mint_on_test_container.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +export PS4='\e[36m+ ${FUNCNAME:-main}\e[0m@\e[32m${BASH_SOURCE}:\e[35m${LINENO} \e[0m' + +set -e +# It will add to the logs every line that we run +set -x + +# ==================================================================================== +# Set the environment variables +export email='admin@noobaa.io' +export password=123456789 + +export SERVER_ADDRESS=localhost +export ENDPOINT_PORT=6001 +export ENDPOINT_SSL_PORT=6443 +export S3_SERVICE_HOST=localhost + +export CEPH_TEST_LOGS_DIR=/logs/mint-nc-test-logs +export CONFIG_DIR=/etc/noobaa.conf.d/ +export FS_ROOT_1=/tmp/nsfs_root1/ +export FS_ROOT_2=/tmp/nsfs_root2/ +export CONFIG_JS_allow_anonymous_access_in_test=true # Needed for allowing anon access for tests using ACL='public-read-write' + +# ==================================================================================== + +# 1. Create configuration directory +# 2. Create config.json file +mkdir -p ${CONFIG_DIR} +config='{"ALLOW_HTTP":true, "ENDPOINT_FORKS":2, "NSFS_CALCULATE_MD5": true}' +echo "$config" > ${CONFIG_DIR}/config.json + +# 1. Create root directory for bucket creation +# 2. Add permission to all users +# this will allow the new accounts to create directories (buckets), +# else we would see [Error: Permission denied] { code: 'EACCES' } +mkdir -p ${FS_ROOT_1} +mkdir -p ${FS_ROOT_2} +chmod 777 ${FS_ROOT_1} +chmod 777 ${FS_ROOT_2} + +# Create the logs directory +mkdir -p ${CEPH_TEST_LOGS_DIR} +chmod 777 ${CEPH_TEST_LOGS_DIR} + +# ==================================================================================== + +# Deploy standalone NooBaa on the test container +# And create the accounts needed for the Ceph tests +./src/deploy/NVA_build/standalone_deploy_nsfs.sh + +# ==================================================================================== + +cd /root/node_modules/noobaa-core/ + +# Configure the mint test +node ./src/test/system_tests/mint/configure_mint.js diff --git a/src/test/system_tests/warp/configure_warp.js b/src/test/system_tests/warp/configure_warp.js index d2e117fd78..2ae123d422 100644 --- a/src/test/system_tests/warp/configure_warp.js +++ b/src/test/system_tests/warp/configure_warp.js @@ -5,7 +5,7 @@ const dbg = require('../../../util/debug_module')(__filename); dbg.set_process_name('test_warp_s3'); const { WARP_TEST } = require('./warp_constants.js'); -const { create_warp_account, create_warp_bucket } = require('./warp_utils.js'); +const { is_containerized_deployment, create_system_test_account, create_system_test_bucket } = require('../external_tests_utils.js'); async function main() { try { @@ -19,8 +19,11 @@ async function main() { async function warp_test_setup() { console.info('WARP TEST CONFIGURATION:', JSON.stringify(WARP_TEST)); - await create_warp_account(); - await create_warp_bucket(); + const is_containerized = is_containerized_deployment(); + const account_options = is_containerized ? WARP_TEST.warp_account_params : WARP_TEST.nc_warp_account_params; + const bucket_options = is_containerized ? WARP_TEST.warp_bucket_params : WARP_TEST.nc_warp_bucket_params; + await create_system_test_account(account_options); + await create_system_test_bucket(account_options, bucket_options); console.info('WARP TEST SETUP DONE'); } diff --git a/src/test/system_tests/warp/run_warp.js b/src/test/system_tests/warp/run_warp.js index 1ac1699d34..b688ce53f7 100644 --- a/src/test/system_tests/warp/run_warp.js +++ b/src/test/system_tests/warp/run_warp.js @@ -8,7 +8,7 @@ delete argv._; const config = require('../../../../config'); const os_utils = require('../../../util/os_utils'); -const { get_warp_access_keys } = require('./warp_utils'); +const { get_account_access_keys } = require('../external_tests_utils'); const { DEFAULT_NUMBER_OF_WORKERS, WARP_TEST } = require('./warp_constants.js'); const usage = ` @@ -81,7 +81,7 @@ async function run_warp() { } if (account_name && !access_key && !secret_key) { - ({ access_key, secret_key } = await get_warp_access_keys(account_name)); + ({ access_key, secret_key } = await get_account_access_keys(account_name)); } // TODO - add --benchdata so that the result csv will be saved in logs