Skip to content

Commit 72ced52

Browse files
committed
warp NC
Signed-off-by: Romy <[email protected]>
1 parent 43c88d2 commit 72ced52

File tree

8 files changed

+256
-79
lines changed

8 files changed

+256
-79
lines changed

.github/workflows/Warp NC Tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
name: Warp NC Tests
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
warp-nc-tests:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 90
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
steps:
13+
- name: Checkout noobaa-core
14+
uses: actions/checkout@v4
15+
with:
16+
repository: 'noobaa/noobaa-core'
17+
path: 'noobaa-core'
18+
19+
- name: Create Warp logs directory
20+
run: |
21+
set -x
22+
cd ./noobaa-core
23+
mkdir -p logs/warp-test-logs
24+
chmod 777 logs/warp-test-logs
25+
26+
- name: Run NC Warp tests
27+
run: |
28+
set -x
29+
cd ./noobaa-core
30+
make test-nc-warp
31+

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ test-cephs3: tester
338338
.PHONY: test-cephs3
339339

340340
test-warp: tester
341-
@echo "\033[1;34mRunning tests with Postgres.\033[0m"
341+
@echo "\033[1;34mRunning warp tests with Postgres.\033[0m"
342342
@$(call create_docker_network)
343343
@$(call run_postgres)
344344
@echo "\033[1;34mRunning warp tests\033[0m"
@@ -348,6 +348,11 @@ test-warp: tester
348348
@$(call remove_docker_network)
349349
.PHONY: test-warp
350350

351+
test-nc-warp: tester
352+
@echo "\033[1;34mRunning warp tests on NC environment\033[0m"
353+
$(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"
354+
.PHONY: test-nc-warp
355+
351356
test-nsfs-cephs3: tester
352357
@echo "\033[1;34mRunning Ceph S3 tests on NSFS Standalone platform\033[0m"
353358
$(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"

src/test/system_tests/ceph_s3_tests/test_ceph_nsfs_s3_config_setup.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ dbg.set_process_name('test_ceph_s3');
1212

1313
const fs = require('fs');
1414
const os_utils = require('../../../util/os_utils');
15-
const test_utils = require('../../system_tests/test_utils');
16-
const { TYPES, ACTIONS } = require('../../../manage_nsfs/manage_nsfs_constants');
1715
const { CEPH_TEST } = require('./test_ceph_s3_constants.js');
16+
const { get_access_keys, create_account } = require('../nc_test_utils');
1817

1918
async function main() {
2019
try {
@@ -73,26 +72,7 @@ async function ceph_test_setup() {
7372
console.info('CEPH TEST CONFIGURATION: DONE');
7473
}
7574

76-
/**
77-
* get_access_keys returns account access keys using noobaa-cli
78-
* @param {string} account_name
79-
*/
80-
async function get_access_keys(account_name) {
81-
const options = { name: account_name, show_secrets: true };
82-
const res = await test_utils.exec_manage_cli(TYPES.ACCOUNT, ACTIONS.STATUS, options);
83-
const json_account = JSON.parse(res);
84-
const account_data = json_account.response.reply;
85-
return account_data.access_keys[0];
86-
}
8775

88-
/**
89-
* create_account creates accounts using noobaa-cli
90-
* @param {{ name?: string, uid?: number, gid?: number, anonymous?: boolean }} [options]
91-
*/
92-
async function create_account(options = {}) {
93-
const res = await test_utils.exec_manage_cli(TYPES.ACCOUNT, ACTIONS.ADD, options);
94-
console.log('Account Created', res);
95-
}
9676

9777
if (require.main === module) {
9878
main();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* Copyright (C) 2016 NooBaa */
2+
'use strict';
3+
4+
const test_utils = require('./test_utils');
5+
const { TYPES, ACTIONS } = require('../../manage_nsfs/manage_nsfs_constants');
6+
7+
/**
8+
* get_access_keys returns account access keys using noobaa-cli
9+
* @param {string} account_name
10+
*/
11+
async function get_access_keys(account_name) {
12+
const account_data = await get_account(account_name);
13+
return account_data.access_keys[0];
14+
}
15+
16+
/**
17+
* get_account returns account data using noobaa-cli
18+
* @param {string} account_name
19+
*/
20+
async function get_account(account_name) {
21+
const options = { name: account_name, show_secrets: true };
22+
const res = await test_utils.exec_manage_cli(TYPES.ACCOUNT, ACTIONS.STATUS, options);
23+
const json_account = JSON.parse(res);
24+
const account_data = json_account.response.reply;
25+
return account_data;
26+
}
27+
28+
/**
29+
* create_account creates account using noobaa-cli
30+
* @param {{ name?: string, uid?: number, gid?: number, anonymous?: boolean }} [options]
31+
*/
32+
async function create_account(options = {}) {
33+
const res = await test_utils.exec_manage_cli(TYPES.ACCOUNT, ACTIONS.ADD, options);
34+
console.log('NC Account Created', res);
35+
}
36+
37+
/**
38+
* create_bucket creates bucket using noobaa-cli
39+
* @param {{ name?: string, owner?: string, path?: string}} [options]
40+
*/
41+
async function create_bucket(options = {}) {
42+
const res = await test_utils.exec_manage_cli(TYPES.BUCKET, ACTIONS.ADD, options);
43+
console.log('NC Bucket Created', res);
44+
}
45+
46+
// EXPORTS
47+
exports.get_account = get_account;
48+
exports.get_access_keys = get_access_keys;
49+
exports.create_account = create_account;
50+
exports.create_bucket = create_bucket;

src/test/system_tests/warp/configure_warp.js

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,22 @@
11
/* Copyright (C) 2016 NooBaa */
22
"use strict";
33

4-
/**
5-
* This script is used as a part of the CI/CD process to run all Warp S3 tests.
6-
* It creates the prior configuration needed.
7-
*/
8-
94
const dbg = require('../../../util/debug_module')(__filename);
105
dbg.set_process_name('test_warp_s3');
116

127
const { WARP_TEST } = require('./warp_constants.js');
13-
const { get_authenticated_global_rpc_client, get_rpc_client_by_email_and_password } = require('./warp_utils.js');
8+
const { create_warp_account, create_warp_bucket } = require('./warp_utils.js');
149

1510
async function main() {
1611
try {
17-
await run_test();
12+
await warp_test_setup();
1813
} catch (err) {
1914
console.error(`Warp Setup Failed: ${err}`);
2015
process.exit(1);
2116
}
2217
process.exit(0);
2318
}
2419

25-
async function run_test() {
26-
try {
27-
await warp_test_setup();
28-
} catch (err) {
29-
console.error('Failed setup Warp tests', err);
30-
throw new Error('Failed setup Warp tests');
31-
}
32-
}
33-
34-
async function create_warp_account() {
35-
const global_rpc_client = await get_authenticated_global_rpc_client();
36-
const system = await global_rpc_client.system.read_system();
37-
// We are taking the first host pool, in normal k8s setup is default backing store
38-
const test_pool = system.pools.filter(p => p.resource_type === 'HOSTS')[0];
39-
console.log(test_pool);
40-
try {
41-
await global_rpc_client.account.create_account({
42-
...WARP_TEST.warp_account_params,
43-
default_resource: test_pool.name
44-
});
45-
console.info('WARP account created:', WARP_TEST.warp_account_params);
46-
} catch (err) {
47-
console.log("Failed to create account or tenant, assuming they were already created and continuing. ", err.message);
48-
}
49-
}
50-
51-
async function create_warp_bucket() {
52-
try {
53-
const { email, password } = WARP_TEST.warp_account_params;
54-
const warp_account_rpc_client = await get_rpc_client_by_email_and_password(email, password);
55-
await warp_account_rpc_client.bucket.create_bucket({
56-
name: WARP_TEST.warp_bucket_params.name,
57-
});
58-
console.info('WARP bucket created:', WARP_TEST.warp_bucket_params);
59-
} catch (err) {
60-
console.log("Failed to create bucket, assuming they were already created and continuing. ", err.message);
61-
}
62-
}
63-
6420
async function warp_test_setup() {
6521
console.info('WARP TEST CONFIGURATION:', JSON.stringify(WARP_TEST));
6622
await create_warp_account();
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
export PS4='\e[36m+ ${FUNCNAME:-main}\e[0m@\e[32m${BASH_SOURCE}:\e[35m${LINENO} \e[0m'
4+
5+
set -e
6+
# It will add to the logs every line that we run
7+
set -x
8+
9+
# ====================================================================================
10+
# Set the environment variables
11+
export email='[email protected]'
12+
export password=123456789
13+
14+
export ENDPOINT_PORT=6001
15+
export ENDPOINT_SSL_PORT=6443
16+
export S3_SERVICE_HOST=localhost
17+
18+
export CEPH_TEST_LOGS_DIR=/logs/warp-nc-test-logs
19+
export CONFIG_DIR=/etc/noobaa.conf.d/
20+
export FS_ROOT_1=/tmp/nsfs_root1/
21+
export FS_ROOT_2=/tmp/nsfs_root2/
22+
export WARP_BUCKET_PATH=${FS_ROOT_1}/warp-benchmark-bucket/
23+
export CONFIG_JS_allow_anonymous_access_in_test=true # Needed for allowing anon access for tests using ACL='public-read-write'
24+
25+
# ====================================================================================
26+
27+
# 1. Create configuration directory
28+
# 2. Create config.json file
29+
mkdir -p ${CONFIG_DIR}
30+
config='{"ALLOW_HTTP":true, "ENDPOINT_FORKS":2}'
31+
echo "$config" > ${CONFIG_DIR}/config.json
32+
33+
# 1. Create root directory for bucket creation
34+
# 2. Add permission to all users
35+
# this will allow the new accounts to create directories (buckets),
36+
# else we would see [Error: Permission denied] { code: 'EACCES' }
37+
mkdir -p ${FS_ROOT_1}
38+
mkdir -p ${FS_ROOT_2}
39+
mkdir -p ${WARP_BUCKET_PATH}
40+
chmod 777 ${FS_ROOT_1}
41+
chmod 777 ${FS_ROOT_2}
42+
chmod 777 ${WARP_BUCKET_PATH}
43+
44+
# Create the logs directory
45+
mkdir -p ${CEPH_TEST_LOGS_DIR}
46+
47+
48+
# ====================================================================================
49+
50+
# Install warp
51+
curl -L https://github.com/minio/warp/releases/download/v1.1.4/warp_Linux_x86_64.tar.gz -o warp_Linux_x86_64.tar.gz
52+
tar -xzf warp_Linux_x86_64.tar.gz
53+
chmod +x warp
54+
mv warp /usr/local/bin/warp
55+
warp --version
56+
57+
# ====================================================================================
58+
59+
# Deploy standalone NooBaa on the test container
60+
# And create the accounts needed for the Ceph tests
61+
./src/deploy/NVA_build/standalone_deploy_nsfs.sh
62+
63+
# ====================================================================================
64+
65+
cd /root/node_modules/noobaa-core/
66+
67+
# Configure the warp test
68+
node ./src/test/system_tests/warp/configure_warp.js
69+
70+
# ====================================================================================
71+
72+
# Run the warp tests
73+
node ./src/test/system_tests/warp/run_warp.js
74+
75+
# ====================================================================================

src/test/system_tests/warp/warp_constants.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* Copyright (C) 2022 NooBaa */
2-
"use strict";
2+
'use strict';
33

44
const warp_account_name = 'warp_account';
55
const warp_bucket_name = 'warp-benchmark-bucket';
66

77
// NC warp tests paths for bucket creation
88
const FS_ROOT_1 = '/tmp/nsfs_root1/';
99
const FS_ROOT_2 = '/tmp/nsfs_root2/';
10+
const warp_nc_bucket_path = `${FS_ROOT_1}${warp_bucket_name}/`;
1011

1112
const WARP_TEST = {
1213
s3_test_dir: 's3-tests/',
@@ -22,6 +23,17 @@ const WARP_TEST = {
2223
warp_bucket_params: {
2324
name: warp_bucket_name
2425
},
26+
nc_warp_account_params: {
27+
name: warp_account_name,
28+
uid: 1000,
29+
gid: 1000,
30+
new_buckets_path: FS_ROOT_1
31+
},
32+
nc_warp_bucket_params: {
33+
name: warp_bucket_name,
34+
owner: warp_account_name,
35+
path: warp_nc_bucket_path,
36+
},
2537
nc_anonymous_account_params: {
2638
anonymous: true,
2739
uid: process.getuid(),

0 commit comments

Comments
 (0)