Skip to content

Commit

Permalink
Simplified the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Aug 13, 2024
1 parent 04d8221 commit f86d757
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ services:
target: test
environment:
TEST_FAAS_STARTUP_DEPLOY: ${TEST_FAAS_STARTUP_DEPLOY:-false}
TEST_FAAS_DEPENDENCY_DEPLOY: ${TEST_FAAS_DEPENDENCY_DEPLOY:-false}
NODE_ENVIRONMENT: ${NODE_ENVIRONMENT:-development}
network_mode: host
depends_on:
- faas
Expand Down
25 changes: 20 additions & 5 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Integration tests, first docker compose up runs the normal test.
set -exuo pipefail

if [ -x "$(command -v docker-compose)" ]; then
DOCKER_CMD=docker-compose
else
docker compose &>/dev/null

if [ $? -eq 0 ]; then
DOCKER_CMD="docker compose"
else
echo "ERROR: neither \"docker-compose\" nor \"docker compose\" appear to be installed."
exit 1
fi
fi

# Integration tests: first docker compose up runs the normal test.
# The second one runs the test without deleting the FaaS container,
# and the environment varialbe TEST_FAAS_STARTUP_DEPLOY forces the
# test to avoid deploying again all the deployments. By this we are
# testing if the startup initialization works because the deployments
# are persisted from the previous run

docker compose build
NODE_ENVIRONMENT=deployment TEST_FAAS_DEPENDENCY_DEPLOY=true docker compose up --exit-code-from test
TEST_FAAS_STARTUP_DEPLOY=true TEST_FAAS_DEPENDENCY_DEPLOY=true NODE_ENVIRONMENT=deployment docker compose up --exit-code-from test
docker compose down
${DOCKER_CMD} build
${DOCKER_CMD} up --exit-code-from test
TEST_FAAS_STARTUP_DEPLOY=true ${DOCKER_CMD} up --exit-code-from test
${DOCKER_CMD} down
18 changes: 4 additions & 14 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# You can enable this for debugging in development by changing NODE_ENVIRONMENT to development.
if [[ "${NODE_ENVIRONMENT}" == "deployment" ]]; then
set -exuo pipefail
fi
set -exuo pipefail

# Maximum number of retries
MAX_RETRIES=5
Expand Down Expand Up @@ -94,13 +91,8 @@ function run_tests() {

echo "Inspection test passed."

# Call delete functionality in local development
if [[ "${NODE_ENVIRONMENT}" == "development" && "${TEST_FAAS_STARTUP_DEPLOY}" == "false" ]]; then
delete_functionality $app $prefix
fi

# Call delete functionality
if [[ "${TEST_FAAS_STARTUP_DEPLOY}" == "true" && "${NODE_ENVIRONMENT}" == "deployment" ]]; then
if [[ "${TEST_FAAS_STARTUP_DEPLOY}" == "true" ]]; then
delete_functionality $app $prefix
fi
}
Expand Down Expand Up @@ -196,9 +188,7 @@ function test_nodejs_dependency_app() {
# Run tests
run_tests "nodejs-base-app" test_nodejs_app
run_tests "python-base-app" test_python_base_app
if [[ "${TEST_FAAS_DEPENDENCY_DEPLOY}" == "true" ]]; then
run_tests "python-dependency-app" test_python_dependency_app
run_tests "nodejs-dependency-app" test_nodejs_dependency_app
fi
run_tests "python-dependency-app" test_python_dependency_app
run_tests "nodejs-dependency-app" test_nodejs_dependency_app

echo "Integration tests passed without errors."

0 comments on commit f86d757

Please sign in to comment.