-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NC | lifecycle | add abort multipart upload handler
Signed-off-by: nadav mizrahi <[email protected]>
- Loading branch information
Showing
6 changed files
with
184 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/unit_tests/jest_tests/test_nc_lifecycle_cli.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* Copyright (C) 2016 NooBaa */ | ||
'use strict'; | ||
|
||
// disabling init_rand_seed as it takes longer than the actual test execution | ||
process.env.DISABLE_INIT_RANDOM_SEED = 'true'; | ||
|
||
const path = require('path'); | ||
const fs_utils = require('../../../util/fs_utils'); | ||
const { ConfigFS } = require('../../../sdk/config_fs'); | ||
const { TMP_PATH, set_nc_config_dir_in_config, TEST_TIMEOUT, exec_manage_cli } = require('../../system_tests/test_utils'); | ||
const BucketSpaceFS = require('../../../sdk/bucketspace_fs'); | ||
const { TYPES, ACTIONS } = require('../../../manage_nsfs/manage_nsfs_constants'); | ||
|
||
const new_umask = process.env.NOOBAA_ENDPOINT_UMASK || 0o000; | ||
const old_umask = process.umask(new_umask); | ||
console.log('test_nc_lifecycle_cli: replacing old umask: ', old_umask.toString(8), 'with new umask: ', new_umask.toString(8)); | ||
|
||
const config_root = path.join(TMP_PATH, 'config_root_nc_lifecycle'); | ||
const root_path = path.join(TMP_PATH, 'root_path_nc_lifecycle/'); | ||
const config_fs = new ConfigFS(config_root); | ||
|
||
function make_dummy_object_sdk(account_json) { | ||
return { | ||
requesting_account: account_json | ||
}; | ||
} | ||
|
||
|
||
describe('noobaa cli - lifecycle', () => { | ||
const bucketspace_fs = new BucketSpaceFS({ config_root }, undefined); | ||
const test_bucket = 'test-bucket'; | ||
const test_bucket2 = 'test-bucket2'; | ||
const account_options1 = {uid: 2002, gid: 2002, new_buckets_path: root_path, name: 'user2', config_root, allow_bucket_creation: "true"}; | ||
|
||
beforeAll(async () => { | ||
await fs_utils.create_fresh_path(config_root, 0o777); | ||
set_nc_config_dir_in_config(config_root); | ||
await fs_utils.create_fresh_path(root_path, 0o777); | ||
const res = await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.ADD, account_options1); | ||
const json_account = JSON.parse(res).response.reply; | ||
console.log(json_account); | ||
const dummy_sdk = make_dummy_object_sdk(json_account); | ||
await bucketspace_fs.create_bucket({ name: test_bucket }, dummy_sdk); | ||
await bucketspace_fs.create_bucket({ name: test_bucket2 }, dummy_sdk); | ||
}); | ||
|
||
afterEach(async () => { | ||
await bucketspace_fs.delete_bucket_lifecycle({ name: test_bucket }); | ||
await bucketspace_fs.delete_bucket_lifecycle({ name: test_bucket2 }); | ||
}); | ||
|
||
afterAll(async () => { | ||
await fs_utils.folder_delete(`${root_path}/${test_bucket}`); | ||
await fs_utils.folder_delete(`${root_path}/${test_bucket2}`); | ||
await fs_utils.folder_delete(root_path); | ||
await fs_utils.folder_delete(config_root); | ||
}, TEST_TIMEOUT); | ||
|
||
it('lifecycle_cli - abort mpu by number of days ', async () => { | ||
const lifecycle_rule = [ | ||
{ | ||
"id": "abort mpu after 3 days", | ||
"status": "Enabled", | ||
"filter": {"prefix": ""}, | ||
"abort_incomplete_multipart_upload": { | ||
"days_after_initiation": 3 | ||
} | ||
} | ||
]; | ||
await bucketspace_fs.set_bucket_lifecycle_configuration_rules({ name: test_bucket, rules: lifecycle_rule }); | ||
await exec_manage_cli(TYPES.LIFECYCLE, '', {disable_service_validation: "true", config_root}); | ||
}); | ||
|
||
}); |