@@ -8,6 +8,10 @@ setup() {
8
8
export LANG=C.UTF-8
9
9
fi
10
10
export USR_CACHE_DIR=` node -e ' console.log(require("./lib/shared").getUserCachePath())' `
11
+ # Please note: If you update change the requirements.txt in test/base this value will
12
+ # change. Run a test which uses this variable manually step by step and list the cache
13
+ # folder to find the new hash if you do this
14
+ export CACHE_FOLDER_HASH=" b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc"
11
15
if [ -d " ${USR_CACHE_DIR} " ] ; then
12
16
rm -Rf " ${USR_CACHE_DIR} "
13
17
fi
@@ -184,7 +188,7 @@ teardown() {
184
188
perl -p -i' .bak' -e ' s/(pythonRequirements:$)/\1\n useDownloadCache: true\n useStaticCache: true/' serverless.yml
185
189
sls package
186
190
USR_CACHE_DIR=` node -e ' console.log(require("../../lib/shared").getUserCachePath())' `
187
- ls $USR_CACHE_DIR /b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /flask
191
+ ls $USR_CACHE_DIR /$CACHE_FOLDER_HASH /flask
188
192
ls $USR_CACHE_DIR /downloadCacheslspyc/http
189
193
}
190
194
@@ -195,7 +199,7 @@ teardown() {
195
199
perl -p -i' .bak' -e ' s/(pythonRequirements:$)/\1\n useDownloadCache: true\n useStaticCache: true/' serverless.yml
196
200
sls --dockerizePip=true package
197
201
USR_CACHE_DIR=` node -e ' console.log(require("../../lib/shared").getUserCachePath())' `
198
- ls $USR_CACHE_DIR /b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /flask
202
+ ls $USR_CACHE_DIR /$CACHE_FOLDER_HASH /flask
199
203
ls $USR_CACHE_DIR /downloadCacheslspyc/http
200
204
}
201
205
@@ -206,8 +210,8 @@ teardown() {
206
210
perl -p -i' .bak' -e ' s/(pythonRequirements:$)/\1\n useStaticCache: true/' serverless.yml
207
211
sls package
208
212
USR_CACHE_DIR=` node -e ' console.log(require("../../lib/shared").getUserCachePath())' `
209
- ls $USR_CACHE_DIR /b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /flask
210
- ls $USR_CACHE_DIR /b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /.completed_requirements
213
+ ls $USR_CACHE_DIR /$CACHE_FOLDER_HASH /flask
214
+ ls $USR_CACHE_DIR /$CACHE_FOLDER_HASH /.completed_requirements
211
215
}
212
216
213
217
@test " py3.6 uses static cache with cacheLocation option" {
@@ -217,8 +221,8 @@ teardown() {
217
221
perl -p -i' .bak' -e ' s/(pythonRequirements:$)/\1\n useStaticCache: true\n cacheLocation: .requirements-cache/' serverless.yml
218
222
sls package
219
223
USR_CACHE_DIR=` node -e ' console.log(require("../../lib/shared").getUserCachePath())' `
220
- ls .requirements-cache/b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /flask
221
- ls .requirements-cache/b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /.completed_requirements
224
+ ls .requirements-cache/$CACHE_FOLDER_HASH /flask
225
+ ls .requirements-cache/$CACHE_FOLDER_HASH /.completed_requirements
222
226
}
223
227
224
228
@test " py3.6 checking that static cache actually pulls from cache (by poisoning it)" {
@@ -229,18 +233,30 @@ teardown() {
229
233
sls package
230
234
cp .serverless/sls-py-req-test.zip ./puck
231
235
USR_CACHE_DIR=` node -e ' console.log(require("../../lib/shared").getUserCachePath())' `
232
- echo " injected new file into static cache folder" > $USR_CACHE_DIR /b8b9d2be59f6f2ea5778e8b2aa4d2ddc_slspyc /injected_file_is_bad_form
236
+ echo " injected new file into static cache folder" > $USR_CACHE_DIR /$CACHE_FOLDER_HASH /injected_file_is_bad_form
233
237
sls package
234
238
[ ` wc -c ./.serverless/sls-py-req-test.zip | awk ' { print $1 }' ` -gt ` wc -c ./puck | awk ' { print $1 }' ` ]
235
239
}
236
240
237
- @test " py3.6 uses cache with dockerizePip & slim option" {
241
+ @test " py3.6 uses static cache with dockerizePip & slim option" {
238
242
cd tests/base
239
243
npm i $( npm pack ../..)
240
244
! uname -sm| grep Linux || groups| grep docker || id -u| egrep ' ^0$' || skip " can't dockerize on linux if not root & not in docker group"
241
245
perl -p -i' .bak' -e ' s/(pythonRequirements:$)/\1\n useStaticCache: true/' serverless.yml
242
- sls --slim=true package
243
- ls .requirements-cache/http
246
+ sls --dockerizePip=true --slim=true package
247
+ ls $USR_CACHE_DIR /$CACHE_FOLDER_HASH /flask
248
+ unzip .serverless/sls-py-req-test.zip -d puck
249
+ test $( find puck -name " *.pyc" | wc -l) -eq 0
250
+ }
251
+
252
+ @test " py3.6 uses download cache with dockerizePip & slim option" {
253
+ cd tests/base
254
+ npm i $( npm pack ../..)
255
+ ! uname -sm| grep Linux || groups| grep docker || id -u| egrep ' ^0$' || skip " can't dockerize on linux if not root & not in docker group"
256
+ perl -p -i' .bak' -e ' s/(pythonRequirements:$)/\1\n useDownloadCache: true/' serverless.yml
257
+ sls --dockerizePip=true --slim=true package
258
+ ls $USR_CACHE_DIR /downloadCacheslspyc/http
259
+ unzip .serverless/sls-py-req-test.zip -d puck
244
260
test $( find puck -name " *.pyc" | wc -l) -eq 0
245
261
}
246
262
0 commit comments