General-purpose upgrade
This commit is contained in:
parent
3748eefb8e
commit
b6812793f9
18 changed files with 286 additions and 165 deletions
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# Keep a vector of {xpath, namespace} pairs, match xpath in parsed XML and check if symbols belong to namespace
|
||||
# If not, set that namespace.
|
||||
# This is a primitive upgrade mechanism if th emore general upgrade mechanism can not be used
|
||||
# Test of the general-purpose (raw) upgrade mechanism.
|
||||
# Input is a startup db without mod-state info.
|
||||
# It has wrong namespace bindings and needs to remove some nodes
|
||||
# Output is a valid config woith correct namespaces and removed nods
|
||||
# The code for this is in the main example backend plugin.
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
|
@ -40,6 +42,12 @@ module A{
|
|||
container y {
|
||||
}
|
||||
}
|
||||
list remove_me {
|
||||
key k;
|
||||
leaf k {
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
@ -65,7 +73,48 @@ EOF
|
|||
# permission kludges
|
||||
sudo touch $dir/startup_db
|
||||
sudo chmod 666 $dir/startup_db
|
||||
|
||||
# This is how it should look after repair, using prefixes
|
||||
AFTER=$(cat <<EOF
|
||||
<x xmlns="urn:example:a"><y><b:z xmlns:b="urn:example:b"><b:w>foo</b:w></b:z></y></x>
|
||||
EOF
|
||||
)
|
||||
|
||||
testrun(){
|
||||
new "test params: -f $cfg"
|
||||
# Bring your own backend
|
||||
if [ $BE -ne 0 ]; then
|
||||
# kill old backend (if any)
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
new "start backend -s startup -f $cfg"
|
||||
start_backend -s startup -f $cfg
|
||||
|
||||
new "waiting"
|
||||
wait_backend
|
||||
fi
|
||||
|
||||
new "netconf get config"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply><data>$AFTER</data></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
if [ -z "$pid" ]; then
|
||||
err "backend already dead"
|
||||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
} # end testrun
|
||||
|
||||
# Create startup db of "old" db with incorrect augment namespace tagging
|
||||
# without modstate
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<x xmlns="urn:example:a">
|
||||
|
|
@ -75,44 +124,12 @@ cat <<EOF > $dir/startup_db
|
|||
</z>
|
||||
</y>
|
||||
</x>
|
||||
<remove_me xmlns="urn:example:a"><k>This node is obsolete</k></remove_me>
|
||||
<remove_me xmlns="urn:example:a"><k>this too</k></remove_me>
|
||||
</config>
|
||||
EOF
|
||||
|
||||
# This is how it should look after repair, using prefixes
|
||||
AFTER=$(cat <<EOF
|
||||
<x xmlns="urn:example:a"><y><b:z xmlns:b="urn:example:b"><b:w>foo</b:w></b:z></y></x>
|
||||
EOF
|
||||
)
|
||||
new "general-purpose upgrade without modstate"
|
||||
testrun
|
||||
|
||||
# Or using default:
|
||||
# <config><x xmlns="urn:example:a"><y><z xmlns="urn:example:b"><w>foo</w></z></y></x></config>
|
||||
|
||||
new "test params: -f $cfg"
|
||||
# Bring your own backend
|
||||
if [ $BE -ne 0 ]; then
|
||||
# kill old backend (if any)
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
new "start backend -s startup -f $cfg"
|
||||
start_backend -s startup -f $cfg
|
||||
|
||||
new "waiting"
|
||||
wait_backend
|
||||
fi
|
||||
|
||||
new "netconf get config"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply><data>$AFTER</data></rpc-reply>]]>]]>$"
|
||||
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
if [ -z "$pid" ]; then
|
||||
err "backend already dead"
|
||||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
|
||||
#rm -rf $dir
|
||||
rm -rf $dir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue