11const ScfUtils = require ( './index' ) ;
2+ const CFS = require ( '../cfs' ) ;
23
34class ClientTest {
45 async scfTest ( ) {
5- const scf = new ScfUtils ( {
6+ const credentials = {
67 SecretId : '' ,
78 SecretKey : '' ,
8- } ) ;
9+ } ;
10+ const scf = new ScfUtils ( credentials ) ;
911 const inputs = {
1012 name : 'express-test' ,
1113 code : {
1214 bucket : 'sls-cloudfunction-ap-guangzhou-code' ,
13- object : 'express_component_5dwuabh-1597994417 .zip' ,
15+ object : 'express_component_5dwuabh-1598513206 .zip' ,
1416 } ,
1517 role : 'SCF_QcsRole' ,
1618 handler : 'sl_handler.handler' ,
@@ -29,6 +31,16 @@ class ClientTest {
2931 } ,
3032 } ,
3133 eip : true ,
34+ vpcConfig : {
35+ vpcId : 'vpc-cp54x9m7' ,
36+ subnetId : 'subnet-267yufru' ,
37+ } ,
38+ cfs : [
39+ {
40+ localMountDir : '/mnt/' ,
41+ remoteMountDir : '/' ,
42+ } ,
43+ ] ,
3244 events : [
3345 {
3446 timer : {
@@ -69,6 +81,24 @@ class ClientTest {
6981 ] ,
7082 } ;
7183
84+ // 0. deploy cfs
85+ const cfsInputs = {
86+ fsName : 'cfs-test' ,
87+ region : 'ap-guangzhou' ,
88+ zone : 'ap-guangzhou-3' ,
89+ netInterface : 'VPC' ,
90+ vpc : {
91+ vpcId : 'vpc-cp54x9m7' ,
92+ subnetId : 'subnet-267yufru' ,
93+ } ,
94+ } ;
95+ const cfsClient = new CFS ( credentials , inputs . region ) ;
96+ const cfsRes = await cfsClient . deploy ( cfsInputs ) ;
97+ console . log ( 'cfs deploy: ' , JSON . stringify ( cfsRes ) ) ;
98+ console . log ( '++++++++++++++++++' ) ;
99+ inputs . cfs [ 0 ] . cfsId = cfsRes . fileSystemId ;
100+
101+
72102 // 1. deploy test
73103 const res1 = await scf . deploy ( inputs ) ;
74104 console . log ( 'deploy: ' , JSON . stringify ( res1 ) ) ;
@@ -106,6 +136,9 @@ class ClientTest {
106136 await scf . remove ( {
107137 functionName : inputs . name ,
108138 } ) ;
139+
140+ // 5. remove cfs
141+ await cfsClient . remove ( cfsRes ) ;
109142 }
110143}
111144
0 commit comments