|
| 1 | +#!/bin/bash -ex |
| 2 | +# |
| 3 | +# Copyright (C) 2020 HERE Europe B.V. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# SPDX-License-Identifier: Apache-2.0 |
| 18 | +# License-Filename: LICENSE |
| 19 | + |
| 20 | +# Set workspace location |
| 21 | +if [[ ${CI_PROJECT_DIR} == "" ]]; then |
| 22 | + export CI_PROJECT_DIR=`pwd` |
| 23 | +fi |
| 24 | + |
| 25 | +[[ -d "reports" ]] && rm -rf reports |
| 26 | + |
| 27 | +#echo ">>> Installing mock server SSL certificate into OS... >>>" |
| 28 | +#curl https://raw.githubusercontent.com/mock-server/mockserver/master/mockserver-core/src/main/resources/org/mockserver/socket/CertificateAuthorityCertificate.pem --output mock-server-cert.cer |
| 29 | +#certutil -enterprise -f -v -addstore "Root" mock-server-cert.cer |
| 30 | +#certutil -enterprise -f -v -addstore "CA" mock-server-cert.cer |
| 31 | + |
| 32 | + |
| 33 | +echo ">>> Starting Mock Server... >>>" |
| 34 | +pushd tests/utils/mock-server |
| 35 | + npm install |
| 36 | + node server.js & export SERVER_PID=$! |
| 37 | +popd |
| 38 | + |
| 39 | +# Node can start server in 1 second, but not faster. |
| 40 | +# Add waiter for server to be started. No other way to solve that. |
| 41 | +# Curl returns code 1 - means server still down. Curl returns 0 when server is up |
| 42 | +RC=1 |
| 43 | +while [[ ${RC} -ne 0 ]]; |
| 44 | +do |
| 45 | + set +e |
| 46 | + curl -s http://localhost:1080 |
| 47 | + RC=$? |
| 48 | + sleep 0.2 |
| 49 | + set -e |
| 50 | +done |
| 51 | + |
| 52 | +echo ">>> Start network tests ... >>>" |
| 53 | +$CI_PROJECT_DIR/build/tests/functional/network/RelWithDebInfo/olp-cpp-sdk-functional-network-tests \ |
| 54 | + --gtest_output="xml:$CI_PROJECT_DIR/reports/olp-functional-network-test-report.xml" |
| 55 | +result=$? |
| 56 | +echo ">>> Finished network tests >>>" |
| 57 | + |
| 58 | +# Terminate the mock server |
| 59 | +kill -TERM $SERVER_PID |
| 60 | + |
| 61 | +wait |
| 62 | + |
| 63 | +exit ${result} |
0 commit comments