Skip to content

Commit af6eb96

Browse files
committed
NSFS
Signed-off-by: nadav mizrahi <nadav.mizrahi16@gmail.com>
1 parent 5b07689 commit af6eb96

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

src/test/system_tests/test_utils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ const { CONFIG_TYPES } = require('../../sdk/config_fs');
1515
const native_fs_utils = require('../../util/native_fs_utils');
1616
const { NodeHttpHandler } = require("@smithy/node-http-handler");
1717

18+
const GPFS_ROOT_PATH = process.env.GPFS_ROOT_PATH;
19+
const IS_GPFS = !_.isUndefined(GPFS_ROOT_PATH);
20+
const TMP_PATH = get_tmp_path();
21+
1822
/**
1923
* TMP_PATH is a path to the tmp path based on the process platform
2024
* in contrast to linux, /tmp/ path on mac is a symlink to /private/tmp/
25+
* on gpfs should point to GPFS file system. should create tmp dir on file system and pass it as process.env.GPFS_ROOT_PATH
2126
*/
22-
const TMP_PATH = os_utils.IS_MAC ? '/private/tmp/' : '/tmp/';
27+
function get_tmp_path() {
28+
if (os_utils.IS_MAC) {
29+
return '/private/tmp/';
30+
} else if (IS_GPFS) {
31+
return GPFS_ROOT_PATH;
32+
} else {
33+
return '/tmp/';
34+
}
35+
}
36+
2337

2438
/**
2539
* is_nc_coretest returns true when the test runs on NC env
@@ -606,6 +620,7 @@ exports.set_path_permissions_and_owner = set_path_permissions_and_owner;
606620
exports.set_nc_config_dir_in_config = set_nc_config_dir_in_config;
607621
exports.generate_anon_s3_client = generate_anon_s3_client;
608622
exports.TMP_PATH = TMP_PATH;
623+
exports.IS_GPFS = IS_GPFS;
609624
exports.is_nc_coretest = is_nc_coretest;
610625
exports.generate_nsfs_account = generate_nsfs_account;
611626
exports.get_new_buckets_path_by_test_env = get_new_buckets_path_by_test_env;

src/test/unit_tests/jest_tests/test_versioning_concurrency.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const P = require('../../../util/promise');
77
const fs_utils = require('../../../util/fs_utils');
88
const NamespaceFS = require('../../../sdk/namespace_fs');
99
const buffer_utils = require('../../../util/buffer_utils');
10-
const { TMP_PATH } = require('../../system_tests/test_utils');
10+
const { TMP_PATH, IS_GPFS } = require('../../system_tests/test_utils');
1111
const { crypto_random_string } = require('../../../util/string_utils');
1212
const endpoint_stats_collector = require('../../../sdk/endpoint_stats_collector');
1313
const SECONDS = 1000;
@@ -19,7 +19,7 @@ function make_dummy_object_sdk(nsfs_config, uid, gid) {
1919
nsfs_account_config: nsfs_config && {
2020
uid: uid || process.getuid(),
2121
gid: gid || process.getgid(),
22-
backend: '',
22+
backend: IS_GPFS ? 'GPFS' : '',
2323
}
2424
},
2525
abort_controller: new AbortController(),

src/test/unit_tests/test_bucketspace.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const { stat, open } = require('../../util/nb_native')().fs;
1919
const { get_process_fs_context } = require('../../util/native_fs_utils');
2020
const { TYPES } = require('../../manage_nsfs/manage_nsfs_constants');
2121
const ManageCLIError = require('../../manage_nsfs/manage_nsfs_cli_errors').ManageCLIError;
22-
const { TMP_PATH, is_nc_coretest, get_coretest_path, invalid_nsfs_root_permissions,
22+
const { TMP_PATH, IS_GPFS, is_nc_coretest, get_coretest_path, invalid_nsfs_root_permissions,
2323
generate_s3_policy, create_fs_user_by_platform, delete_fs_user_by_platform, get_new_buckets_path_by_test_env,
2424
generate_s3_client, exec_manage_cli, generate_anon_s3_client, generate_nsfs_account } = require('../system_tests/test_utils');
2525
const nc_mkm = require('../../manage_nsfs/nc_master_key_manager').get_instance();
@@ -37,7 +37,7 @@ coretest.setup({});
3737
let CORETEST_ENDPOINT;
3838
const inspect = (x, max_arr = 5) => util.inspect(x, { colors: true, depth: null, maxArrayLength: max_arr });
3939

40-
const DEFAULT_FS_CONFIG = get_process_fs_context();
40+
const DEFAULT_FS_CONFIG = get_process_fs_context(IS_GPFS ? 'GPFS' : '');
4141
const new_account_params = {
4242
has_login: false,
4343
s3_access: true,
@@ -147,6 +147,7 @@ mocha.describe('bucket operations - namespace_fs', function() {
147147
}
148148
});
149149
mocha.it('export other dir as bucket - and update bucket path to original bucket path', async function() {
150+
this.timeout(600000); // eslint-disable-line no-invalid-this
150151
const obj_nsr = { resource: nsr, path: bucket_path };
151152
const other_obj_nsr = { resource: nsr, path: other_bucket_path };
152153
// give read and write permission to owner
@@ -188,6 +189,7 @@ mocha.describe('bucket operations - namespace_fs', function() {
188189
});
189190

190191
mocha.it('list buckets without uid, gid', async function() {
192+
this.timeout(600000); // eslint-disable-line no-invalid-this
191193
// Give s3_owner access to the required buckets
192194
const generated = generate_s3_policy(EMAIL, first_bucket, ['s3:*']);
193195
await rpc_client.bucket.put_bucket_policy({ name: first_bucket, policy: generated.policy });
@@ -576,11 +578,13 @@ mocha.describe('bucket operations - namespace_fs', function() {
576578
const s3_xattr = {}; // invalid xattr won't return on s3 head object
577579
await tmpfile.replacexattr(DEFAULT_FS_CONFIG, fs_xattr);
578580
const xattr_res = (await tmpfile.stat(DEFAULT_FS_CONFIG)).xattr;
581+
//filter unrelated xattr added by operating system
582+
const xattr_res_filtered = _.pickBy(xattr_res, (val, name) => name.startsWith("user."));
579583
await tmpfile.close(DEFAULT_FS_CONFIG);
580584

581585
const head_res = await s3_client.headObject({ Bucket: bucket, Key: key });
582586
assert.deepStrictEqual(head_res.Metadata, s3_xattr);
583-
assert.deepStrictEqual(fs_xattr, xattr_res);
587+
assert.deepStrictEqual(fs_xattr, xattr_res_filtered);
584588
const get_res = await s3_client.getObject({ Bucket: bucket, Key: key });
585589
assert.deepStrictEqual(get_res.Metadata, s3_xattr);
586590
await s3_client.deleteObject({ Bucket: bucket, Key: key });
@@ -599,11 +603,13 @@ mocha.describe('bucket operations - namespace_fs', function() {
599603
const s3_xattr = { 'key1.2.3': encoded_xattr };
600604
await tmpfile.replacexattr(DEFAULT_FS_CONFIG, fs_xattr);
601605
const xattr_res = (await tmpfile.stat(DEFAULT_FS_CONFIG)).xattr;
606+
//filter unrelated xattr added by operating system
607+
const xattr_res_filtered = _.pickBy(xattr_res, (val, name) => name.startsWith("user."));
602608
await tmpfile.close(DEFAULT_FS_CONFIG);
603609

604610
const head_res = await s3_client.headObject({ Bucket: bucket, Key: key });
605611
assert.deepStrictEqual(head_res.Metadata, s3_xattr);
606-
assert.deepStrictEqual(fs_xattr, xattr_res);
612+
assert.deepStrictEqual(fs_xattr, xattr_res_filtered);
607613
const get_res = await s3_client.getObject({ Bucket: bucket, Key: key });
608614
assert.deepStrictEqual(get_res.Metadata, s3_xattr);
609615
await s3_client.deleteObject({ Bucket: bucket, Key: key });
@@ -818,6 +824,7 @@ mocha.describe('bucket operations - namespace_fs', function() {
818824
});
819825

820826
mocha.it('delete bucket with uid, gid - bucket is empty', async function() {
827+
this.timeout(600000); // eslint-disable-line no-invalid-this
821828
const res = await s3_correct_uid_default_nsr.deleteBucket({ Bucket: bucket_name + '-s3' });
822829
console.log(inspect(res));
823830
});
@@ -924,6 +931,7 @@ mocha.describe('bucket operations - namespace_fs', function() {
924931
}
925932
});
926933
mocha.it('delete bucket with uid, gid - bucket is empty', async function() {
934+
this.timeout(600000); // eslint-disable-line no-invalid-this
927935
// Give s3_correct_uid_default_nsr access to the required buckets
928936
await Promise.all(
929937
[bucket_name + '-other1', bucket_name]
@@ -1148,6 +1156,7 @@ mocha.describe('nsfs account configurations', function() {
11481156
await fs_utils.folder_delete(tmp_fs_root1);
11491157
});
11501158
mocha.it('export dir as a bucket', async function() {
1159+
this.timeout(600000); // eslint-disable-line no-invalid-this
11511160
await rpc_client.pool.create_namespace_resource({
11521161
name: nsr1,
11531162
nsfs_config: {
@@ -1628,6 +1637,7 @@ mocha.describe('list buckets - namespace_fs', async function() {
16281637
});
16291638

16301639
mocha.it('account1 - all accounts are allowed to list bucket1', async function() {
1640+
this.timeout(50000); // eslint-disable-line no-invalid-this
16311641
// allow all accounts to list bucket1
16321642
const public_bucket = accounts.account1.bucket;
16331643
const bucket_policy = generate_s3_policy('*', public_bucket, ['s3:ListBucket']);
@@ -1666,6 +1676,7 @@ mocha.describe('list buckets - namespace_fs', async function() {
16661676
});
16671677

16681678
mocha.it('account2 - set allow only account1 list bucket2, account1/account2 can list bucket2 but account3 cant', async function() {
1679+
this.timeout(50000); // eslint-disable-line no-invalid-this
16691680
const bucket2 = accounts.account2.bucket;
16701681
const account_name = 'account1';
16711682
// on NC the account identifier is account name, and on containerized it's the account's email

src/test/unit_tests/test_bucketspace_versioning.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const P = require('../../util/promise');
1212
const fs_utils = require('../../util/fs_utils');
1313
const nb_native = require('../../util/nb_native');
1414
const size_utils = require('../../util/size_utils');
15-
const { TMP_PATH, is_nc_coretest, set_path_permissions_and_owner, generate_nsfs_account, get_new_buckets_path_by_test_env,
15+
const { TMP_PATH, IS_GPFS, is_nc_coretest, set_path_permissions_and_owner, generate_nsfs_account, get_new_buckets_path_by_test_env,
1616
invalid_nsfs_root_permissions, generate_s3_client, get_coretest_path } = require('../system_tests/test_utils');
1717
const { get_process_fs_context } = require('../../util/native_fs_utils');
1818

@@ -27,7 +27,7 @@ const XATTR_DELETE_MARKER = XATTR_INTERNAL_NOOBAA_PREFIX + 'delete_marker';
2727
const NULL_VERSION_ID = 'null';
2828
const HIDDEN_VERSIONS_PATH = '.versions';
2929

30-
const DEFAULT_FS_CONFIG = get_process_fs_context();
30+
const DEFAULT_FS_CONFIG = get_process_fs_context(IS_GPFS ? 'GPFS' : '');
3131
let CORETEST_ENDPOINT;
3232

3333
const tmp_fs_root = path.join(TMP_PATH, 'test_bucket_namespace_fs_versioning');

0 commit comments

Comments
 (0)