@@ -9,16 +9,16 @@ const P = require('../../util/promise');
9
9
const mocha = require ( 'mocha' ) ;
10
10
const assert = require ( 'assert' ) ;
11
11
const fs_utils = require ( '../../util/fs_utils' ) ;
12
- const { TMP_PATH , generate_nsfs_account, get_new_buckets_path_by_test_env, generate_s3_client,
13
- get_coretest_path, exec_manage_cli } = require ( '../system_tests/test_utils' ) ;
12
+ const { TMP_PATH , generate_nsfs_account, get_new_buckets_path_by_test_env, generate_s3_client, get_coretest_path, exec_manage_cli } = require ( '../system_tests/test_utils' ) ;
14
13
const { TYPES , ACTIONS } = require ( '../../manage_nsfs/manage_nsfs_constants' ) ;
15
14
const ManageCLIResponse = require ( '../../manage_nsfs/manage_nsfs_cli_responses' ) . ManageCLIResponse ;
16
15
17
16
const coretest_path = get_coretest_path ( ) ;
18
17
const coretest = require ( coretest_path ) ;
19
18
const setup_options = { forks : 2 , debug : 5 } ;
20
19
coretest . setup ( setup_options ) ;
21
- const { rpc_client, EMAIL , get_current_setup_options, stop_nsfs_process, start_nsfs_process, config_dir_name } = coretest ;
20
+ const { rpc_client, EMAIL , get_current_setup_options, stop_nsfs_process, start_nsfs_process,
21
+ config_dir_name, NC_CORETEST_CONFIG_FS , NC_CORETEST_STORAGE_PATH } = coretest ;
22
22
23
23
const CORETEST_ENDPOINT = coretest . get_http_address ( ) ;
24
24
@@ -52,6 +52,7 @@ mocha.describe('operations with a couple of forks', async function() {
52
52
53
53
mocha . after ( async ( ) => {
54
54
fs_utils . folder_delete ( `${ config_root } ` ) ;
55
+ fs_utils . folder_delete ( `${ new_bucket_path_param } ` ) ;
55
56
} ) ;
56
57
57
58
mocha . it ( 'versioning change with a couple of forks' , async function ( ) {
@@ -147,4 +148,79 @@ mocha.describe('operations with a couple of forks', async function() {
147
148
// cleanup
148
149
await s3_uid5_after_access_keys_update . deleteBucket ( { Bucket : bucket_name2 } ) ;
149
150
} ) ;
151
+
152
+ mocha . it ( 'head a bucket after account update (change fs_backend)' , async function ( ) {
153
+ // create additional account
154
+ const account_name = 'Oliver' ;
155
+ const account_options_create = { account_name, uid : 6001 , gid : 6001 , config_root : config_dir_name } ;
156
+ await fs_utils . create_fresh_path ( new_bucket_path_param ) ;
157
+ await fs . promises . chown ( new_bucket_path_param , account_options_create . uid , account_options_create . gid ) ;
158
+ await fs . promises . chmod ( new_bucket_path_param , 0o700 ) ;
159
+ const access_details = await generate_nsfs_account ( rpc_client , EMAIL , new_bucket_path_param , account_options_create ) ;
160
+ // check the account status
161
+ const account_options_status = { config_root : config_dir_name , name : account_name } ;
162
+ const res_account_status = await exec_manage_cli ( TYPES . ACCOUNT , ACTIONS . STATUS , account_options_status ) ;
163
+ assert . equal ( JSON . parse ( res_account_status ) . response . code , ManageCLIResponse . AccountStatus . code ) ;
164
+ // generate the s3 client
165
+ const s3_uid6001 = generate_s3_client ( access_details . access_key ,
166
+ access_details . secret_key , CORETEST_ENDPOINT ) ;
167
+ // check the connection for the new account (can be any of the forks)
168
+ const res_list_buckets = await s3_uid6001 . listBuckets ( { } ) ;
169
+ assert . equal ( res_list_buckets . $metadata . httpStatusCode , 200 ) ;
170
+ // create a bucket
171
+ const bucket_name3 = 'bucket3' ;
172
+ const res_bucket_create = await s3_uid6001 . createBucket ( { Bucket : bucket_name3 } ) ;
173
+ assert . equal ( res_bucket_create . $metadata . httpStatusCode , 200 ) ;
174
+ // head the bucket
175
+ const res_head_bucket1 = await s3_uid6001 . headBucket ( { Bucket : bucket_name3 } ) ;
176
+ assert . equal ( res_head_bucket1 . $metadata . httpStatusCode , 200 ) ;
177
+ // update the account
178
+ const account_options_update = { config_root : config_dir_name , name : account_name , fs_backend : 'GPFS' } ;
179
+ const res_account_update = await exec_manage_cli ( TYPES . ACCOUNT , ACTIONS . UPDATE , account_options_update ) ;
180
+ assert . equal ( JSON . parse ( res_account_update ) . response . code , ManageCLIResponse . AccountUpdated . code ) ;
181
+ // head the bucket (again)
182
+ const res_head_bucket2 = await s3_uid6001 . headBucket ( { Bucket : bucket_name3 } ) ;
183
+ assert . equal ( res_head_bucket2 . $metadata . httpStatusCode , 200 ) ;
184
+
185
+ // cleanup
186
+ await s3_uid6001 . deleteBucket ( { Bucket : bucket_name3 } ) ;
187
+ } ) ;
188
+
189
+ mocha . it ( 'create a bucket after account update (change buckets_path)' , async function ( ) {
190
+ // create an additional account
191
+ const account_name = 'John' ;
192
+ const account_options_create = { account_name, uid : 7001 , gid : 7001 , config_root : config_dir_name } ;
193
+ // reuse NC_CORETEST_STORAGE_PATH as new_buckets_path (no need for create fresh path, chmod and chown)
194
+ const access_details = await generate_nsfs_account ( rpc_client , EMAIL , NC_CORETEST_STORAGE_PATH , account_options_create ) ;
195
+ // check the account status
196
+ const account_options_status = { config_root : config_dir_name , name : account_name } ;
197
+ const res_account_status = await exec_manage_cli ( TYPES . ACCOUNT , ACTIONS . STATUS , account_options_status ) ;
198
+ assert . equal ( JSON . parse ( res_account_status ) . response . code , ManageCLIResponse . AccountStatus . code ) ;
199
+ // generate the s3 client
200
+ const s3_uid6001 = generate_s3_client ( access_details . access_key ,
201
+ access_details . secret_key , CORETEST_ENDPOINT ) ;
202
+ // check the connection for the new account (can be any of the forks)
203
+ const res_list_buckets = await s3_uid6001 . listBuckets ( { } ) ;
204
+ assert . equal ( res_list_buckets . $metadata . httpStatusCode , 200 ) ;
205
+ // update the account - change its new_bucket_path
206
+ const new_bucket_path_param2 = path . join ( TMP_PATH , 'nc_coretest_storage_root_path2/' ) ;
207
+ await fs_utils . create_fresh_path ( new_bucket_path_param2 ) ;
208
+ await fs . promises . chown ( new_bucket_path_param2 , account_options_create . uid , account_options_create . gid ) ;
209
+ await fs . promises . chmod ( new_bucket_path_param2 , 0o700 ) ;
210
+ const account_options_update = { config_root : config_dir_name , name : account_name , new_buckets_path : new_bucket_path_param2 } ;
211
+ const res_account_update = await exec_manage_cli ( TYPES . ACCOUNT , ACTIONS . UPDATE , account_options_update ) ;
212
+ assert . equal ( JSON . parse ( res_account_update ) . response . code , ManageCLIResponse . AccountUpdated . code ) ;
213
+ // create a bucket
214
+ const bucket_name4 = 'bucket4' ;
215
+ const res_bucket_create = await s3_uid6001 . createBucket ( { Bucket : bucket_name4 } ) ;
216
+ assert . equal ( res_bucket_create . $metadata . httpStatusCode , 200 ) ;
217
+ // validate the bucket was created in the updated path
218
+ const bucket4 = await NC_CORETEST_CONFIG_FS . get_bucket_by_name ( bucket_name4 ) ;
219
+ const expected_bucket_path = path . join ( new_bucket_path_param2 , bucket_name4 ) ;
220
+ assert . equal ( bucket4 . path , expected_bucket_path ) ;
221
+
222
+ // cleanup
223
+ await s3_uid6001 . deleteBucket ( { Bucket : bucket_name4 } ) ;
224
+ await fs . promises . rm ( new_bucket_path_param2 , { recursive : true } ) ;
225
+ } ) ;
150
226
} ) ;
0 commit comments