aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/netconf-pnp-simulator/engine/common.sh
diff options
context:
space:
mode:
authorebo <eliezio.oliveira@est.tech>2020-04-19 01:33:21 +0100
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-20 07:11:26 +0000
commitee0c74e28de9552e683724264b101362c144694c (patch)
tree84aef9e38cbdd4c88e25f3bbbe6bff6af703fb20 /test/mocks/netconf-pnp-simulator/engine/common.sh
parent93d2ff22d0c8c1bc1fc7a2ea5e5643c88a345667 (diff)
netconf-pnp-simulator: fix sysrepod crash on TLS reconfig
The crash was caused by: - the '--permanent' option while updating the ietf-keystore by sysrepocfg - missing some Yang modules on sysrepo installation Other changes: 1. Added TLS integration tests, including reconfiguration 2. reconfigure-*.sh are now synchronous, only returnig after restart is completed Issue-ID: INT-1516 Change-Id: Iddc03fc968aaab60931596045437ba0c78448b08 Signed-off-by: ebo <eliezio.oliveira@est.tech>
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)