@@ -215,23 +215,6 @@ describe('Spanner', () => {
215215 await pg_database . updateSchema ( schema ) ;
216216 await postgreSqlOperationUpdateDDL . promise ( ) ;
217217 RESOURCES_TO_CLEAN . push ( PG_DATABASE ) ;
218-
219- // Create a user-managed instance config from a base instance config.
220- const [ baseInstanceConfig ] = await spanner . getInstanceConfig (
221- INSTANCE_CONFIG . config
222- ) ;
223- const customInstanceConfigRequest = {
224- replicas : baseInstanceConfig . replicas ! . concat (
225- baseInstanceConfig ! . optionalReplicas ! [ 0 ]
226- ) ,
227- baseConfig : baseInstanceConfig . name ,
228- gaxOptions : GAX_OPTIONS ,
229- } ;
230- const [ , operation ] = await instanceConfig . create (
231- customInstanceConfigRequest
232- ) ;
233- await operation . promise ( ) ;
234- INSTANCE_CONFIGS_TO_CLEAN . push ( instanceConfig ) ;
235218 }
236219 } ) ;
237220
@@ -272,15 +255,6 @@ describe('Spanner', () => {
272255 } catch ( err ) {
273256 console . error ( 'Cleanup failed:' , err ) ;
274257 }
275- /**
276- * Deleting instance configs created during this test.
277- * @see {@link https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstanceConfig }
278- */
279- await Promise . all (
280- INSTANCE_CONFIGS_TO_CLEAN . map ( instanceConfig =>
281- instanceConfig . delete ( { gaxOpts : GAX_OPTIONS } )
282- )
283- ) ;
284258 } ) ;
285259
286260 describe ( 'Autogenerated Admin Client' , async ( ) => {
@@ -2187,6 +2161,39 @@ describe('Spanner', () => {
21872161 } ) ;
21882162
21892163 describe ( 'instanceConfigs' , ( ) => {
2164+ before ( async ( ) => {
2165+ if ( ! IS_EMULATOR_ENABLED ) {
2166+ // Create a user-managed instance config from a base instance config.
2167+ const [ baseInstanceConfig ] = await spanner . getInstanceConfig (
2168+ INSTANCE_CONFIG . config
2169+ ) ;
2170+ const customInstanceConfigRequest = {
2171+ replicas : baseInstanceConfig . replicas ! . concat (
2172+ baseInstanceConfig ! . optionalReplicas ! [ 0 ]
2173+ ) ,
2174+ baseConfig : baseInstanceConfig . name ,
2175+ gaxOptions : GAX_OPTIONS ,
2176+ } ;
2177+ const [ , operation ] = await instanceConfig . create (
2178+ customInstanceConfigRequest
2179+ ) ;
2180+ await operation . promise ( ) ;
2181+ INSTANCE_CONFIGS_TO_CLEAN . push ( instanceConfig ) ;
2182+ }
2183+ } ) ;
2184+
2185+ after ( async ( ) => {
2186+ /**
2187+ * Deleting instance configs created during this test.
2188+ * @see {@link https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstanceConfig }
2189+ */
2190+ await Promise . all (
2191+ INSTANCE_CONFIGS_TO_CLEAN . map ( instanceConfig =>
2192+ instanceConfig . delete ( { gaxOpts : GAX_OPTIONS } )
2193+ )
2194+ ) ;
2195+ } ) ;
2196+
21902197 it ( 'should have created the instance config' , function ( done ) {
21912198 if ( IS_EMULATOR_ENABLED ) {
21922199 this . skip ( ) ;
@@ -3952,13 +3959,13 @@ describe('Spanner', () => {
39523959 const [ sessions ] = await dbNewRole . batchCreateSessions ( { count} ) ;
39533960
39543961 assert . strictEqual ( sessions . length , count ) ;
3955- sessions . forEach ( session =>
3956- session . getMetadata ( ( err , metadata ) => {
3957- assert . ifError ( err ) ;
3958- assert . strictEqual ( 'parent_role' , metadata ?. databaseRole ) ;
3962+ await Promise . all (
3963+ sessions . map ( async session => {
3964+ const metadata = await session . getMetadata ( ) ;
3965+ assert . strictEqual ( 'parent_role' , metadata [ 0 ] . databaseRole ) ;
3966+ await session . delete ( ) ;
39593967 } )
39603968 ) ;
3961- await Promise . all ( sessions . map ( session => session . delete ( ) ) ) ;
39623969 } ) ;
39633970
39643971 it ( 'should batch create sessions with database role by overriding session database-role' , async function ( ) {
@@ -3972,13 +3979,13 @@ describe('Spanner', () => {
39723979 } ) ;
39733980
39743981 assert . strictEqual ( sessions . length , count ) ;
3975- sessions . forEach ( session =>
3976- session . getMetadata ( ( err , metadata ) => {
3977- assert . ifError ( err ) ;
3978- assert . strictEqual ( 'child_role' , metadata ?. databaseRole ) ;
3982+ await Promise . all (
3983+ sessions . map ( async session => {
3984+ const metadata = await session . getMetadata ( ) ;
3985+ assert . strictEqual ( 'child_role' , metadata [ 0 ] . databaseRole ) ;
3986+ await session . delete ( ) ;
39793987 } )
39803988 ) ;
3981- await Promise . all ( sessions . map ( session => session . delete ( ) ) ) ;
39823989 } ) ;
39833990
39843991 it ( 'should batch create sessions with database role by overriding database-role' , async function ( ) {
@@ -3992,13 +3999,13 @@ describe('Spanner', () => {
39923999 } ) ;
39934000
39944001 assert . strictEqual ( sessions . length , count ) ;
3995- sessions . forEach ( session =>
3996- session . getMetadata ( ( err , metadata ) => {
3997- assert . ifError ( err ) ;
3998- assert . strictEqual ( 'orphan_role' , metadata ?. databaseRole ) ;
4002+ await Promise . all (
4003+ sessions . map ( async session => {
4004+ const metadata = await session . getMetadata ( ) ;
4005+ assert . strictEqual ( 'orphan_role' , metadata [ 0 ] . databaseRole ) ;
4006+ await session . delete ( ) ;
39994007 } )
40004008 ) ;
4001- await Promise . all ( sessions . map ( session => session . delete ( ) ) ) ;
40024009 } ) ;
40034010 } ) ;
40044011
0 commit comments