-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest-e2e-functions.sh
More file actions
executable file
·68 lines (58 loc) · 2.23 KB
/
Copy pathtest-e2e-functions.sh
File metadata and controls
executable file
·68 lines (58 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Script to run the gated Azure Functions host E2E tests.
#
# This mirrors scripts/test-e2e-azuremanaged.sh. The suite launches a real
# Azure Functions host ("func start") for test/e2e-functions/test-app, backed by
# Azurite (the local Azure Storage emulator), and drives it over HTTP.
#
# The test-app depends on the PUBLISHED durable-functions / @azure/functions
# packages, so it installs and builds without any in-repo package build.
#
# Prerequisites (the suite SKIPS cleanly if any are missing):
# - Azure Functions Core Tools ('func') v4 on PATH
# - Azurite reachable on 127.0.0.1:10000 (started here if the 'azurite' CLI is
# installed and the port is free)
set -uo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TEST_APP_DIR="$ROOT_DIR/test/e2e-functions/test-app"
AZURITE_HOST="127.0.0.1"
AZURITE_BLOB_PORT="10000"
started_azurite=""
azurite_up() {
(exec 3<>"/dev/tcp/$AZURITE_HOST/$AZURITE_BLOB_PORT") 2>/dev/null && exec 3>&- 3<&-
}
if ! azurite_up; then
if command -v azurite >/dev/null 2>&1; then
echo "Starting Azurite..."
AZURITE_DATA="$(mktemp -d)"
azurite --silent --location "$AZURITE_DATA" \
--blobPort 10000 --queuePort 10001 --tablePort 10002 &
started_azurite="$!"
for _ in $(seq 1 30); do
azurite_up && break
sleep 1
done
else
echo "Azurite is not running and 'azurite' is not installed; the suite will skip."
fi
fi
# Install + build the ported BasicNode app against the published durable-functions
# package so 'func start' has a dist/ to serve. If this fails there is no app to
# run, so fail fast instead of letting the suite skip and masking the error.
echo "Installing + building test-app..."
if ! ( cd "$TEST_APP_DIR" && npm install && npm run build ); then
echo "test-app install/build failed." >&2
if [ -n "$started_azurite" ]; then
echo "Stopping Azurite..."
kill "$started_azurite" 2>/dev/null || true
fi
exit 1
fi
echo "Running Functions host E2E tests..."
( cd "$ROOT_DIR" && npm run test:e2e:functions:internal )
status=$?
if [ -n "$started_azurite" ]; then
echo "Stopping Azurite..."
kill "$started_azurite" 2>/dev/null || true
fi
exit $status