Skip to content

Commit 20d8f05

Browse files
authored
Merge pull request #8971 from romayalon/romy-flaky-timeout-test
NC | CI | fix lifecycle timeout flaky test
2 parents bbebeac + 97c6e11 commit 20d8f05

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/test/unit_tests/jest_tests/test_nc_lifecycle_cli.test.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ console.log('test_nc_lifecycle_cli: replacing old umask: ', old_umask.toString(8
2929
const config_root = path.join(TMP_PATH, 'config_root_nc_lifecycle');
3030
const root_path = path.join(TMP_PATH, 'root_path_nc_lifecycle/');
3131
const config_fs = new ConfigFS(config_root);
32+
const account_options1 = { uid: 2002, gid: 2002, new_buckets_path: root_path, name: 'user2', config_root, allow_bucket_creation: 'true' };
33+
const test_bucket = 'test-bucket';
34+
const test_bucket1 = 'test-bucket1';
3235

3336
const yesterday = new Date();
3437
yesterday.setDate(yesterday.getDate() - 1); // yesterday
@@ -138,15 +141,13 @@ describe('noobaa cli - lifecycle - lock check', () => {
138141

139142
describe('noobaa cli - lifecycle', () => {
140143
const bucketspace_fs = new BucketSpaceFS({ config_root }, undefined);
141-
const test_bucket = 'test-bucket';
142144
const test_bucket_path = `${root_path}/${test_bucket}`;
143145
const test_bucket2 = 'test-bucket2';
144146
const test_bucket2_path = `${root_path}/${test_bucket2}`;
145147
const test_key1 = 'test_key1';
146148
const test_key2 = 'test_key2';
147149
const prefix = 'test/';
148150
const test_prefix_key = `${prefix}/test_key1`;
149-
const account_options1 = {uid: 2002, gid: 2002, new_buckets_path: root_path, name: 'user2', config_root, allow_bucket_creation: 'true'};
150151
let dummy_sdk;
151152
let nsfs;
152153

@@ -439,6 +440,15 @@ describe('noobaa cli lifecycle - timeout check', () => {
439440
await fs_utils.create_fresh_path(config_root, 0o777);
440441
set_nc_config_dir_in_config(config_root);
441442
await fs_utils.create_fresh_path(root_path, 0o777);
443+
const res = await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.ADD, account_options1);
444+
const json_account = JSON.parse(res).response.reply;
445+
console.log(json_account);
446+
const object_sdk = new NsfsObjectSDK('', config_fs, json_account, "DISABLED", config_fs.config_root, undefined);
447+
object_sdk.requesting_account = json_account;
448+
// don't delete this bucket creation - it's being used for making sure that the lifecycle run will take more than 1 ms
449+
await object_sdk.create_bucket({ name: test_bucket });
450+
await object_sdk.create_bucket({ name: test_bucket1});
451+
442452
});
443453

444454
afterEach(async () => {
@@ -455,19 +465,18 @@ describe('noobaa cli lifecycle - timeout check', () => {
455465
await config_fs.create_config_json_file(JSON.stringify({ NC_LIFECYCLE_TIMEOUT_MS: 1 }));
456466
const res1 = await exec_manage_cli(TYPES.LIFECYCLE, '', { disable_service_validation: 'true', disable_runtime_validation: 'true', config_root }, true, undefined);
457467
await config_fs.delete_config_json_file();
458-
const parsed_res1 = JSON.parse(res1.stdout).error;
459-
expect(parsed_res1.code).toBe(ManageCLIError.LifecycleWorkerReachedTimeout.code);
460-
expect(parsed_res1.message).toBe(ManageCLIError.LifecycleWorkerReachedTimeout.message);
468+
const parsed_res1 = JSON.parse(res1.stdout);
469+
const actual_error = parsed_res1.error;
470+
expect(actual_error.code).toBe(ManageCLIError.LifecycleWorkerReachedTimeout.code);
471+
expect(actual_error.message).toBe(ManageCLIError.LifecycleWorkerReachedTimeout.message);
461472
});
462473
});
463474

464475
describe('noobaa cli - lifecycle batching', () => {
465476
const bucketspace_fs = new BucketSpaceFS({ config_root }, undefined);
466-
const test_bucket = 'test-bucket';
467477
const test_bucket_path = `${root_path}/${test_bucket}`;
468478
const test_key1 = 'test_key1';
469479
const test_key2 = 'test_key2';
470-
const account_options1 = {uid: 2002, gid: 2002, new_buckets_path: root_path, name: 'user2', config_root, allow_bucket_creation: 'true'};
471480
let object_sdk;
472481
const tmp_lifecycle_logs_dir_path = path.join(root_path, 'test_lifecycle_logs');
473482

@@ -634,7 +643,7 @@ describe('noobaa cli - lifecycle batching', () => {
634643
try {
635644
await exec_manage_cli(TYPES.LIFECYCLE, '', {disable_service_validation: 'true', disable_runtime_validation: 'true', config_root}, undefined, undefined);
636645
} catch (e) {
637-
//ignore error
646+
//ignore timout error
638647
}
639648
await exec_manage_cli(TYPES.LIFECYCLE, '', {continue: 'true', disable_service_validation: 'true', disable_runtime_validation: 'true', config_root}, undefined, undefined);
640649
const object_list2 = await object_sdk.list_objects({bucket: test_bucket});
@@ -687,11 +696,9 @@ describe('noobaa cli - lifecycle batching', () => {
687696
});
688697

689698
describe('noobaa cli - lifecycle notifications', () => {
690-
const test_bucket = 'test-bucket';
691699
const test_bucket_path = `${root_path}/${test_bucket}`;
692700
const test_key1 = 'test_key1';
693701
const test_key2 = 'test_key2';
694-
const account_options1 = {uid: 2002, gid: 2002, new_buckets_path: root_path, name: 'user2', config_root, allow_bucket_creation: 'true'};
695702
let object_sdk;
696703
const tmp_lifecycle_logs_dir_path = path.join(root_path, 'test_lifecycle_notifications_logs');
697704
const tmp_conn_dir_path = path.join(root_path, 'test_notification_logs');

0 commit comments

Comments
 (0)