|
1 | 1 | /* Copyright (C) 2016 NooBaa */
|
2 |
| -/*eslint max-lines-per-function: ['error', 700]*/ |
| 2 | +/*eslint max-lines-per-function: ['error', 800]*/ |
3 | 3 |
|
4 | 4 | 'use strict';
|
5 | 5 |
|
@@ -27,6 +27,7 @@ const DEFAULT_FS_CONFIG = get_process_fs_context();
|
27 | 27 |
|
28 | 28 | const bucket_storage_path = path.join(tmp_fs_path, 'bucket_storage_path');
|
29 | 29 | const os = require('os');
|
| 30 | +const { health_warnings } = require('../../../../manage_nsfs/health'); |
30 | 31 | const hostname = os.hostname();
|
31 | 32 |
|
32 | 33 | const valid_system_json = {
|
@@ -134,6 +135,9 @@ mocha.describe('nsfs nc health', function() {
|
134 | 135 | mocha.describe('health check', function() {
|
135 | 136 | this.timeout(10000);// eslint-disable-line no-invalid-this
|
136 | 137 | const new_buckets_path = `${root_path}new_buckets_path_user1/`;
|
| 138 | + const orig_health_buckets_count_limit = config.NC_HEALTH_BUCKETS_COUNT_LIMIT_WARNING; |
| 139 | + const orig_health_accounts_count_limit = config.NC_HEALTH_ACCOUNTS_COUNT_LIMIT_WARNING; |
| 140 | + |
137 | 141 | const account1_options = {
|
138 | 142 | name: 'account1',
|
139 | 143 | uid: process.getuid(),
|
@@ -195,6 +199,8 @@ mocha.describe('nsfs nc health', function() {
|
195 | 199 | mocha.afterEach(async () => {
|
196 | 200 | await fs_utils.file_delete(config_fs.config_json_path);
|
197 | 201 | restore_health_if_needed(Health);
|
| 202 | + config.NC_HEALTH_BUCKETS_COUNT_LIMIT_WARNING = orig_health_buckets_count_limit; |
| 203 | + config.NC_HEALTH_ACCOUNTS_COUNT_LIMIT_WARNING = orig_health_accounts_count_limit; |
198 | 204 | });
|
199 | 205 |
|
200 | 206 | mocha.it('Health all condition is success', async function() {
|
@@ -640,6 +646,89 @@ mocha.describe('nsfs nc health', function() {
|
640 | 646 | await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.DELETE, { config_root, name: account_invalid.name });
|
641 | 647 | });
|
642 | 648 |
|
| 649 | + mocha.it('accounts count below limit', async function() { |
| 650 | + Health.all_account_details = true; |
| 651 | + Health.all_bucket_details = true; |
| 652 | + test_utils.set_health_mock_functions(Health, { |
| 653 | + get_service_state: get_service_state_mock_default_response, |
| 654 | + get_endpoint_response: get_endpoint_response_mock_default_response, |
| 655 | + get_system_config_file: get_system_config_mock_default_response |
| 656 | + }); |
| 657 | + const health_status = await Health.nc_nsfs_health(); |
| 658 | + console.log('health_status', health_status); |
| 659 | + assert.strictEqual(health_status.checks.buckets_status.count, 1); |
| 660 | + assert.strictEqual(health_status.checks.accounts_status.count, 1); |
| 661 | + assert.strictEqual(health_status.warnings.length, 0); |
| 662 | + }); |
| 663 | + |
| 664 | + mocha.it('accounts count above limit - should emit warning', async function() { |
| 665 | + Health.all_account_details = true; |
| 666 | + Health.all_bucket_details = true; |
| 667 | + config.NC_HEALTH_ACCOUNTS_COUNT_LIMIT_WARNING = 0; |
| 668 | + test_utils.set_health_mock_functions(Health, { |
| 669 | + get_service_state: get_service_state_mock_default_response, |
| 670 | + get_endpoint_response: get_endpoint_response_mock_default_response, |
| 671 | + get_system_config_file: get_system_config_mock_default_response |
| 672 | + }); |
| 673 | + const health_status = await Health.nc_nsfs_health(); |
| 674 | + console.log('health_status', health_status); |
| 675 | + assert.strictEqual(health_status.checks.buckets_status.count, 1); |
| 676 | + assert.strictEqual(health_status.checks.accounts_status.count, 1); |
| 677 | + assert.strictEqual(health_status.warnings.length, 1); |
| 678 | + assert.strictEqual(health_status.warnings.includes(health_warnings.ACCOUNTS_COUNT_LIMIT_WARNING), true); |
| 679 | + }); |
| 680 | + |
| 681 | + mocha.it('buckets count below limit', async function() { |
| 682 | + Health.all_account_details = true; |
| 683 | + Health.all_bucket_details = true; |
| 684 | + test_utils.set_health_mock_functions(Health, { |
| 685 | + get_service_state: get_service_state_mock_default_response, |
| 686 | + get_endpoint_response: get_endpoint_response_mock_default_response, |
| 687 | + get_system_config_file: get_system_config_mock_default_response |
| 688 | + }); |
| 689 | + const health_status = await Health.nc_nsfs_health(); |
| 690 | + console.log('health_status', health_status); |
| 691 | + assert.strictEqual(health_status.checks.buckets_status.count, 1); |
| 692 | + assert.strictEqual(health_status.checks.accounts_status.count, 1); |
| 693 | + assert.strictEqual(health_status.warnings.length, 0); |
| 694 | + }); |
| 695 | + |
| 696 | + mocha.it('buckets count above limit - should emit warning', async function() { |
| 697 | + config.NC_HEALTH_BUCKETS_COUNT_LIMIT_WARNING = 0; |
| 698 | + Health.all_account_details = true; |
| 699 | + Health.all_bucket_details = true; |
| 700 | + test_utils.set_health_mock_functions(Health, { |
| 701 | + get_service_state: get_service_state_mock_default_response, |
| 702 | + get_endpoint_response: get_endpoint_response_mock_default_response, |
| 703 | + get_system_config_file: get_system_config_mock_default_response |
| 704 | + }); |
| 705 | + const health_status = await Health.nc_nsfs_health(); |
| 706 | + console.log('health_status', health_status); |
| 707 | + assert.strictEqual(health_status.checks.buckets_status.count, 1); |
| 708 | + assert.strictEqual(health_status.checks.accounts_status.count, 1); |
| 709 | + assert.strictEqual(health_status.warnings.length, 1); |
| 710 | + assert.strictEqual(health_status.warnings.includes(health_warnings.BUCKETS_COUNT_LIMIT_WARNING), true); |
| 711 | + }); |
| 712 | + |
| 713 | + mocha.it('buckets and accounts count above limit - should emit warnings', async function() { |
| 714 | + Health.all_account_details = true; |
| 715 | + Health.all_bucket_details = true; |
| 716 | + config.NC_HEALTH_BUCKETS_COUNT_LIMIT_WARNING = 0; |
| 717 | + config.NC_HEALTH_ACCOUNTS_COUNT_LIMIT_WARNING = 0; |
| 718 | + test_utils.set_health_mock_functions(Health, { |
| 719 | + get_service_state: get_service_state_mock_default_response, |
| 720 | + get_endpoint_response: get_endpoint_response_mock_default_response, |
| 721 | + get_system_config_file: get_system_config_mock_default_response |
| 722 | + }); |
| 723 | + const health_status = await Health.nc_nsfs_health(); |
| 724 | + console.log('health_status', health_status); |
| 725 | + assert.strictEqual(health_status.checks.buckets_status.count, 1); |
| 726 | + assert.strictEqual(health_status.checks.accounts_status.count, 1); |
| 727 | + assert.strictEqual(health_status.warnings.length, 2); |
| 728 | + assert.strictEqual(health_status.warnings.includes(health_warnings.ACCOUNTS_COUNT_LIMIT_WARNING), true); |
| 729 | + assert.strictEqual(health_status.warnings.includes(health_warnings.BUCKETS_COUNT_LIMIT_WARNING), true); |
| 730 | + }); |
| 731 | + |
643 | 732 | mocha.it('Health all condition - failed config directory upgrade status', async function() {
|
644 | 733 | valid_system_json.config_directory = {
|
645 | 734 | config_dir_version: config_fs.config_dir_version,
|
|
0 commit comments