1
1
const ScfUtils = require ( './index' ) ;
2
+ const CFS = require ( '../cfs' ) ;
2
3
3
4
class ClientTest {
4
5
async scfTest ( ) {
5
- const scf = new ScfUtils ( {
6
+ const credentials = {
6
7
SecretId : '' ,
7
8
SecretKey : '' ,
8
- } ) ;
9
+ } ;
10
+ const scf = new ScfUtils ( credentials ) ;
9
11
const inputs = {
10
12
name : 'express-test' ,
11
13
code : {
12
14
bucket : 'sls-cloudfunction-ap-guangzhou-code' ,
13
- object : 'express_component_5dwuabh-1597994417 .zip' ,
15
+ object : 'express_component_5dwuabh-1598513206 .zip' ,
14
16
} ,
15
17
role : 'SCF_QcsRole' ,
16
18
handler : 'sl_handler.handler' ,
@@ -29,6 +31,16 @@ class ClientTest {
29
31
} ,
30
32
} ,
31
33
eip : true ,
34
+ vpcConfig : {
35
+ vpcId : 'vpc-cp54x9m7' ,
36
+ subnetId : 'subnet-267yufru' ,
37
+ } ,
38
+ cfs : [
39
+ {
40
+ localMountDir : '/mnt/' ,
41
+ remoteMountDir : '/' ,
42
+ } ,
43
+ ] ,
32
44
events : [
33
45
{
34
46
timer : {
@@ -69,6 +81,24 @@ class ClientTest {
69
81
] ,
70
82
} ;
71
83
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
+
72
102
// 1. deploy test
73
103
const res1 = await scf . deploy ( inputs ) ;
74
104
console . log ( 'deploy: ' , JSON . stringify ( res1 ) ) ;
@@ -106,6 +136,9 @@ class ClientTest {
106
136
await scf . remove ( {
107
137
functionName : inputs . name ,
108
138
} ) ;
139
+
140
+ // 5. remove cfs
141
+ await cfsClient . remove ( cfsRes ) ;
109
142
}
110
143
}
111
144
0 commit comments