aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/netconf-pnp-simulator/engine/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks/netconf-pnp-simulator/engine/common.sh')
-rw-r--r--test/mocks/netconf-pnp-simulator/engine/common.sh31
1 files changed, 28 insertions, 3 deletions
diff --git a/test/mocks/netconf-pnp-simulator/engine/common.sh b/test/mocks/netconf-pnp-simulator/engine/common.sh
index 961d51f9b..80e882a06 100644
--- a/test/mocks/netconf-pnp-simulator/engine/common.sh
+++ b/test/mocks/netconf-pnp-simulator/engine/common.sh
@@ -62,13 +62,33 @@ find_file() {
# Extracts the body of a PEM file by removing the dashed header and footer
alias pem_body='grep -Fv -- -----'
+wait_for_file() {
+ local file=$1
+ local timeout=$2
+
+ local i=0
+ while [ $i -lt $timeout ]; do
+ if [ -e $file ]; then
+ return
+ fi
+ sleep 1
+ done
+
+ false
+}
kill_service() {
local service=$1
- pid=$(cat /var/run/${service}.pid)
+ pid_file=/run/${service}.pid
+ pid=$(cat $pid_file)
log INFO Killing $service pid=$pid
+ rm -f $pid_file
kill $pid
+ if ! wait_for_file $pid_file 10; then
+ log ERROR Timeout while waiting $service to restart
+ exit 1
+ fi
}
# ------------------------------------
@@ -115,11 +135,16 @@ configure_tls() {
log INFO Load CA and server certificates
ca_cert=$(pem_body $TLS_CONFIG/ca.pem)
server_cert=$(pem_body $TLS_CONFIG/server_cert.pem)
+ out=$(mktemp -p $WORKDIR ietf-keystore.XXXXXX.xml)
xmlstarlet ed --pf --omit-decl \
--update '//_:name[text()="server_cert"]/following-sibling::_:certificate' --value "$server_cert" \
--update '//_:name[text()="ca"]/following-sibling::_:certificate' --value "$ca_cert" \
- $dir/ietf-keystore.xml | \
- sysrepocfg --datastore=$datastore --permanent --format=xml ietf-keystore --${operation}=-
+ $dir/ietf-keystore.xml > $out
+ sysrepocfg --datastore=$datastore --format=xml ietf-keystore --${operation}=$out
+ # The '--permanent' option was causing sysrepod to crash
+ if [ "$datastore" != "startup" ]; then
+ sysrepocfg --datastore=startup --format=xml ietf-keystore --${operation}=$out
+ fi
log INFO Configure TLS ingress service
ca_fingerprint=$(openssl x509 -noout -fingerprint -in $TLS_CONFIG/ca.pem | cut -d= -f2)