|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# MetaCall FaaS Script by Parra Studios |
| 5 | +# Reimplementation of MetaCall FaaS platform written in TypeScript. |
| 6 | +# |
| 7 | +# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]> |
| 8 | +# |
| 9 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | +# you may not use this file except in compliance with the License. |
| 11 | +# You may obtain a copy of the License at |
| 12 | +# |
| 13 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +# |
| 15 | +# Unless required by applicable law or agreed to in writing, software |
| 16 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | +# See the License for the specific language governing permissions and |
| 19 | +# limitations under the License. |
| 20 | +# |
| 21 | + |
| 22 | +set -exuo pipefail |
| 23 | + |
| 24 | +# FaaS base URL |
| 25 | +BASE_URL="http://localhost:9000" |
| 26 | + |
| 27 | +# Get the prefix of a deployment |
| 28 | +function getPrefix() { |
| 29 | + prefix=$(metacall-deploy --dev --inspect Raw | jq -r ".[] | select(.suffix == \"$1\") | .prefix") |
| 30 | + echo $prefix |
| 31 | +} |
| 32 | + |
| 33 | +# Wait for the FaaS to be ready |
| 34 | +while [[ ! $(curl -s -o /dev/null -w "%{http_code}" $BASE_URL/readiness) = "200" ]]; do |
| 35 | + sleep 1 |
| 36 | +done |
| 37 | + |
| 38 | +echo "FaaS ready, starting tests." |
| 39 | + |
| 40 | +# Test deploy (Python) without dependencies |
| 41 | +app="python-base-app" |
| 42 | +pushd data/$app |
| 43 | + metacall-deploy --dev |
| 44 | + prefix=$(getPrefix $app) |
| 45 | + url=$BASE_URL/$prefix/$app/v1/call |
| 46 | + [[ $(curl -s $url/number) = 100 ]] || exit 1 |
| 47 | + [[ $(curl -s $url/text) = '"asd"' ]] || exit 1 |
| 48 | +popd |
0 commit comments