mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #591: Test for onedb upgrade now checks the objects loaded from an upgraded DB.
This commit is contained in:
parent
34585c7402
commit
3f1cd6e540
@ -1,40 +0,0 @@
|
||||
|
||||
if ARGV.length != 2
|
||||
puts "This script requires two file paths to sqlite DBs"
|
||||
exit -1
|
||||
end
|
||||
|
||||
|
||||
file_path_a = ARGV[0]
|
||||
file_path_b = ARGV[1]
|
||||
|
||||
lines_a = Array.new
|
||||
lines_b = Array.new
|
||||
|
||||
|
||||
# The sqlite3 command is used to dump the DB schema it to
|
||||
# a file
|
||||
|
||||
`sqlite3 #{file_path_a} ".schema" > #{file_path_a}.schema`
|
||||
`sqlite3 #{file_path_b} ".schema" > #{file_path_b}.schema`
|
||||
|
||||
# Read the lines into an array
|
||||
File.open( "#{file_path_a}.schema" ) do |f|
|
||||
lines_a = f.readlines
|
||||
end
|
||||
|
||||
File.open( "#{file_path_b}.schema" ) do |f|
|
||||
lines_b = f.readlines
|
||||
end
|
||||
|
||||
|
||||
diff_array = (lines_a | lines_b) - (lines_a & lines_b)
|
||||
|
||||
if !diff_array.empty?
|
||||
puts "Schema does not match. Conflictive lines:"
|
||||
puts diff_array
|
||||
|
||||
exit -1
|
||||
end
|
||||
|
||||
exit 0
|
@ -27,8 +27,6 @@ for i in 0 1 2; do
|
||||
) > $TMP_FILE
|
||||
|
||||
onevnet create $TMP_FILE
|
||||
|
||||
rm $TMP_FILE
|
||||
done
|
||||
|
||||
# 2 Ranged VNets
|
||||
@ -42,8 +40,6 @@ for i in 3 4; do
|
||||
) > $TMP_FILE
|
||||
|
||||
onevnet create $TMP_FILE
|
||||
|
||||
rm $TMP_FILE
|
||||
done
|
||||
|
||||
# 5 Images
|
||||
@ -55,8 +51,6 @@ for i in 0 1 2 3 4; do
|
||||
) > $TMP_FILE
|
||||
|
||||
oneimage create $TMP_FILE
|
||||
|
||||
rm $TMP_FILE
|
||||
done
|
||||
|
||||
# 5 Users
|
||||
@ -100,6 +94,8 @@ for i in 0 1 2 3 4; do
|
||||
onevm deploy $i $i
|
||||
done
|
||||
|
||||
rm $TMP_FILE
|
||||
|
||||
echo -n "Waiting until all VMs are running "
|
||||
|
||||
while [ $(onevm list | grep -c runn) -ne 5 ]; do
|
||||
|
@ -118,10 +118,10 @@ DEFAULT_DEVICE_PREFIX = "hd"
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
IM_MAD = [
|
||||
name = "im_kvm",
|
||||
executable = "one_im_ssh",
|
||||
arguments = "-r 0 -t 15 kvm" ]
|
||||
#IM_MAD = [
|
||||
# name = "im_kvm",
|
||||
# executable = "one_im_ssh",
|
||||
# arguments = "-r 0 -t 15 kvm" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -186,12 +186,12 @@ IM_MAD = [ name="im_dummy", executable="one_im_dummy"]
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
# -p name of the poll probe (executed locally)
|
||||
#-------------------------------------------------------------------------------
|
||||
VM_MAD = [
|
||||
name = "vmm_kvm",
|
||||
executable = "one_vmm_ssh",
|
||||
arguments = "-t 15 -r 0 kvm",
|
||||
default = "vmm_ssh/vmm_ssh_kvm.conf",
|
||||
type = "kvm" ]
|
||||
#VM_MAD = [
|
||||
# name = "vmm_kvm",
|
||||
# executable = "one_vmm_ssh",
|
||||
# arguments = "-t 15 -r 0 kvm",
|
||||
# default = "vmm_ssh/vmm_ssh_kvm.conf",
|
||||
# type = "kvm" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -247,10 +247,10 @@ VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
# NFS Transfer Manager Driver Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
TM_MAD = [
|
||||
name = "tm_nfs",
|
||||
executable = "one_tm",
|
||||
arguments = "tm_nfs/tm_nfs.conf" ]
|
||||
#TM_MAD = [
|
||||
# name = "tm_nfs",
|
||||
# executable = "one_tm",
|
||||
# arguments = "tm_nfs/tm_nfs.conf" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -1,5 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
################################################################################
|
||||
# Initialization
|
||||
################################################################################
|
||||
|
||||
if [ -z $ONE_LOCATION ]; then
|
||||
echo "ONE_LOCATION not defined."
|
||||
exit -1
|
||||
@ -12,16 +16,6 @@ if [ -f $ONEDCONF_LOCATION ]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
cp oned.conf $ONEDCONF_LOCATION
|
||||
|
||||
export ONE_XMLRPC=http://localhost:2888/RPC2
|
||||
export PATH=$ONE_LOCATION/bin:$PATH
|
||||
|
||||
if [ -z $ONE_LOCATION ]; then
|
||||
echo "ONE_LOCATION not defined."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
VAR_LOCATION="$ONE_LOCATION/var"
|
||||
|
||||
if [ -f $VAR_LOCATION/one.db ]; then
|
||||
@ -30,34 +24,112 @@ if [ -f $VAR_LOCATION/one.db ]; then
|
||||
fi
|
||||
|
||||
|
||||
echo "Starting oned, some resources will be created"
|
||||
cp oned.conf $ONEDCONF_LOCATION
|
||||
|
||||
export ONE_XMLRPC=http://localhost:2888/RPC2
|
||||
export PATH=$ONE_LOCATION/bin:$PATH
|
||||
|
||||
PID=$$
|
||||
|
||||
oned -f &
|
||||
|
||||
sleep 2s;
|
||||
|
||||
mkdir results
|
||||
|
||||
################################################################################
|
||||
# Start OpenNebula and populate a DB
|
||||
################################################################################
|
||||
|
||||
echo "Starting oned, some resources will be created"
|
||||
|
||||
oned -f &
|
||||
sleep 2s;
|
||||
|
||||
./create.sh
|
||||
|
||||
pkill -P $PID oned
|
||||
sleep 2s;
|
||||
pkill -9 -P $PID oned
|
||||
|
||||
################################################################################
|
||||
# Upgrade the 2.2 sample DB, and compare schemas
|
||||
################################################################################
|
||||
|
||||
echo "All resources created, now 2.2 DB will be upgraded."
|
||||
|
||||
cp $VAR_LOCATION/one.db results/one.db.3.0
|
||||
cp 2.2/one.db results/one.db.upgraded
|
||||
|
||||
onedb upgrade --sqlite results/one.db.upgraded --backup results/one.db.backup
|
||||
onedb upgrade -v --sqlite results/one.db.upgraded --backup results/one.db.backup
|
||||
|
||||
echo "Done. Upgraded DB and the one created will be compared."
|
||||
echo "Done. Upgraded DB and the one just created will be compared."
|
||||
|
||||
ruby compare_schema.rb results/one.db.upgraded results/one.db.3.0
|
||||
# Dump both DB schemas
|
||||
sqlite3 results/one.db.upgraded ".schema" > results/one.db.upgraded.schema
|
||||
sqlite3 results/one.db.3.0 ".schema" > results/one.db.3.0.schema
|
||||
|
||||
CODE=$?
|
||||
# Sort the files contents, to avoid false diff errors
|
||||
sort results/one.db.upgraded.schema > results/one.db.upgraded.schema
|
||||
sort results/one.db.3.0.schema > results/one.db.3.0.schema
|
||||
|
||||
|
||||
exit $CODE
|
||||
# Perform a diff
|
||||
FILE=results/schema.diff
|
||||
diff results/one.db.upgraded.schema results/one.db.3.0.schema > $FILE
|
||||
|
||||
|
||||
if [[ -s $FILE ]] ; then
|
||||
echo "Error: Schemas do not match. Check file $FILE"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
################################################################################
|
||||
# Start oned using the upgraded DB and compare objects XMLs
|
||||
################################################################################
|
||||
|
||||
echo "Schemas match. OpenNebula 3.0 will be started with the upgraded 2.2 DB."
|
||||
|
||||
cp results/one.db.upgraded $VAR_LOCATION/one.db
|
||||
|
||||
oned -f &
|
||||
sleep 2s;
|
||||
|
||||
for obj in host vnet image vm; do
|
||||
for i in 0 1 2 3 4; do
|
||||
one$obj show -x $i > results/xml_files/$obj-$i-upgraded.xml
|
||||
done
|
||||
done
|
||||
|
||||
pkill -P $PID oned
|
||||
sleep 2s;
|
||||
pkill -9 -P $PID oned
|
||||
|
||||
echo "XML output collected. A diff will be performed."
|
||||
|
||||
mkdir results/diff_files
|
||||
|
||||
for i in 0 1 2 3 4; do
|
||||
diff <(grep -v -e "<LAST_MON_TIME>" -e "<CLUSTER>" -e "NAME>" results/xml_files/host-$i.xml) <(grep -v -e "<LAST_MON_TIME>" -e "<CLUSTER>" -e "NAME>" results/xml_files/host-$i-upgraded.xml) > results/diff_files/host-$i.diff
|
||||
|
||||
diff <(cat results/xml_files/vnet-$i.xml) <(cat results/xml_files/vnet-$i-upgraded.xml) > results/diff_files/vnet-$i.diff
|
||||
|
||||
diff <(grep -v -e "<REGTIME>" -e "<SOURCE>" results/xml_files/image-$i.xml) <(grep -v -e "<REGTIME>" -e "<SOURCE>" results/xml_files/image-$i-upgraded.xml) > results/diff_files/image-$i.diff
|
||||
|
||||
diff <(grep -v -e "<LAST_POLL>" -e "TIME>" -e "<SOURCE>" -e "<TEMPLATE_ID>" -e "<VM_DIR>" results/xml_files/vm-$i.xml) <(grep -v -e "<LAST_POLL>" -e "TIME>" -e "<SOURCE>" -e "<TEMPLATE_ID>" -e "<VM_DIR>" results/xml_files/vm-$i-upgraded.xml) > results/diff_files/vm-$i.diff
|
||||
done
|
||||
|
||||
CODE=0
|
||||
|
||||
for obj in host vnet image vm; do
|
||||
for i in 0 1 2 3 4; do
|
||||
FILE=results/diff_files/$obj-$i.diff
|
||||
if [[ -s $FILE ]] ; then
|
||||
echo "Error: diff file $FILE is not empty."
|
||||
CODE=-1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ $CODE -eq 0 ]; then
|
||||
echo "Done, all tests passed."
|
||||
fi
|
||||
|
||||
exit $CODE
|
||||
|
Loading…
x
Reference in New Issue
Block a user