Skip to content

Commit 16c492f

Browse files
committed
Add test for reinitialization with persistence of the deployments.
1 parent d7ceb57 commit 16c492f

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

.github/workflows/ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ jobs:
4040
# run: |
4141
# npm run test
4242

43+
# Integration tests, first docker compose up runs the normal test.
44+
# The second one runs the test without deleting the FaaS container,
45+
# and the environment varialbe TEST_FAAS_STARTUP_DEPLOY forces the
46+
# test to avoid deploying again all the deployments. By this we are
47+
# testing if the startup initialization works because the deployments
48+
# are persisted from the previous run.
4349
- name: Run Integration Tests
4450
shell: bash
4551
run: |
4652
docker compose build
4753
docker compose up --exit-code-from test
54+
TEST_FAAS_STARTUP_DEPLOY=true docker compose up --exit-code-from test
4855
docker compose down
4956
5057
- name: Publish

docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ services:
3737
context: .
3838
dockerfile: Dockerfile
3939
target: test
40+
environment:
41+
TEST_FAAS_STARTUP_DEPLOY: ${TEST_FAAS_STARTUP_DEPLOY:-false}
4042
network_mode: host
4143
depends_on:
4244
- faas

src/constants.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export const createInstallDependenciesScript = (
1717
path: string
1818
): string => {
1919
const installDependenciesScript: Record<string, string> = {
20-
python: `cd ${path} && echo "some data for the file" >> randomasd.txt && metacall pip3 install -r requirements.txt`,
21-
nodejs: `cd ${path} ; metacall npm i`,
22-
csharp: `cd ${path}; metacall dotnet restore;metacall dotnet release;`,
23-
ruby: `cd ${path}; metacall bundle install`
20+
python: `cd ${path} && metacall pip3 install -r requirements.txt`,
21+
nodejs: `cd ${path} && metacall npm i`,
22+
csharp: `cd ${path} && metacall dotnet restore && metacall dotnet release;`,
23+
ruby: `cd ${path} && metacall bundle install`
2424
};
2525
return installDependenciesScript[runner];
2626
};

test/test.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ function getPrefix() {
3030
echo $prefix
3131
}
3232

33+
# Deploy only if we are not testing startup deployments, otherwise the deployments have been loaded already
34+
function deploy() {
35+
if [[ "${TEST_FAAS_STARTUP_DEPLOY}" != "true" ]]; then
36+
metacall-deploy --dev
37+
fi
38+
}
39+
3340
# Wait for the FaaS to be ready
3441
while [[ ! $(curl -s -o /dev/null -w "%{http_code}" $BASE_URL/readiness) = "200" ]]; do
3542
sleep 1
@@ -40,7 +47,7 @@ echo "FaaS ready, starting tests."
4047
# Test deploy (Python) without dependencies
4148
app="python-base-app"
4249
pushd data/$app
43-
metacall-deploy --dev
50+
deploy
4451
prefix=$(getPrefix $app)
4552
url=$BASE_URL/$prefix/$app/v1/call
4653
[[ $(curl -s $url/number) = 100 ]] || exit 1

0 commit comments

Comments
 (0)