Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.toolbox
Commits
607bfa9f
Commit
607bfa9f
authored
Aug 22, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
KVM test: test all clones if specified.
parent
670b7b38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
64 deletions
+59
-64
slapos/resiliencytest/suites/kvm.py
slapos/resiliencytest/suites/kvm.py
+59
-64
No files found.
slapos/resiliencytest/suites/kvm.py
View file @
607bfa9f
...
@@ -32,7 +32,6 @@ from slapos.recipe.addresiliency.takeover import takeover
...
@@ -32,7 +32,6 @@ from slapos.recipe.addresiliency.takeover import takeover
import
slapos.slap
import
slapos.slap
import
logging
import
logging
import
argparse
import
random
import
random
import
string
import
string
import
time
import
time
...
@@ -46,6 +45,7 @@ def fetchMainInstanceIP(current_partition, software_release, instance_name):
...
@@ -46,6 +45,7 @@ def fetchMainInstanceIP(current_partition, software_release, instance_name):
software_type
=
'kvm-resilient'
,
software_type
=
'kvm-resilient'
,
partition_reference
=
instance_name
).
getConnectionParameter
(
'ipv6'
)
partition_reference
=
instance_name
).
getConnectionParameter
(
'ipv6'
)
def
setRandomKey
(
ip
):
def
setRandomKey
(
ip
):
"""
"""
Set a random key that will be stored inside of the virtual hard drive.
Set a random key that will be stored inside of the virtual hard drive.
...
@@ -85,9 +85,12 @@ def fetchKey(ip):
...
@@ -85,9 +85,12 @@ def fetchKey(ip):
return
new_key
return
new_key
def
runTestSuite
(
server_url
,
key_file
,
cert_file
,
def
runTestSuite
(
server_url
,
key_file
,
cert_file
,
computer_id
,
partition_id
,
software
,
computer_id
,
partition_id
,
software
,
namebase
,
kvm_rootinstance_name
):
namebase
,
kvm_rootinstance_name
,
# Number of instances: main instance (exporter) + clones (importer).
total_instance_count
=
"3"
):
"""
"""
Run KVM Resiliency Test.
Run KVM Resiliency Test.
Requires a specific KVM environment (virtual hard drive), see KVM SR for more
Requires a specific KVM environment (virtual hard drive), see KVM SR for more
...
@@ -106,66 +109,58 @@ def runTestSuite(server_url, key_file, cert_file,
...
@@ -106,66 +109,58 @@ def runTestSuite(server_url, key_file, cert_file,
key
=
setRandomKey
(
ip
)
key
=
setRandomKey
(
ip
)
logger
.
info
(
'Key set for test in current KVM: %s.'
%
key
)
logger
.
info
(
'Key set for test in current KVM: %s.'
%
key
)
# Wait for XX minutes so that replication is done
# In resilient stack, main instance (example with KVM) is named "kvm0",
sleep_time
=
60
*
15
#2 * 60 * 60
# clones are named "kvm1", "kvm2", ...
logger
.
info
(
'Sleeping for %s seconds.'
%
sleep_time
)
clone_count
=
int
(
total_instance_count
)
-
1
time
.
sleep
(
sleep_time
)
# So first clone starts from 1.
current_clone
=
1
# Make the clone instance takeover the main instance
logger
.
info
(
'Replacing main instance by clone instance...'
)
# Test each clone
takeover
(
while
current_clone
<=
clone_count
:
server_url
=
server_url
,
logger
.
info
(
'Testing kvm%s.'
%
current_clone
)
key_file
=
key_file
,
# Wait for XX minutes so that replication is done
cert_file
=
cert_file
,
sleep_time
=
60
*
15
#2 * 60 * 60
computer_guid
=
computer_id
,
logger
.
info
(
'Sleeping for %s seconds.'
%
sleep_time
)
partition_id
=
partition_id
,
time
.
sleep
(
sleep_time
)
software_release
=
software
,
namebase
=
namebase
,
# Make the clone instance takeover the main instance
winner_instance_suffix
=
'1'
,
# XXX: hardcoded value.
logger
.
info
(
'Replacing main instance by clone instance...'
)
)
takeover
(
logger
.
info
(
'Done.'
)
server_url
=
server_url
,
key_file
=
key_file
,
# Wait for the new IP (of old-clone new-main instance) to appear.
cert_file
=
cert_file
,
logger
.
info
(
'Waiting for new main instance to be ready...'
)
computer_guid
=
computer_id
,
new_ip
=
None
partition_id
=
partition_id
,
while
not
new_ip
or
new_ip
==
'None'
or
new_ip
==
ip
:
software_release
=
software
,
logger
.
info
(
'Not ready yet. SlapOS says main IP is %s'
%
new_ip
)
namebase
=
namebase
,
time
.
sleep
(
60
)
winner_instance_suffix
=
str
(
current_clone
),
new_ip
=
fetchMainInstanceIP
(
partition
,
software
,
kvm_rootinstance_name
)
)
logger
.
info
(
'New IP of instance is %s'
%
new_ip
)
logger
.
info
(
'Done.'
)
new_key
=
fetchKey
(
new_ip
)
# Wait for the new IP (of old-clone new-main instance) to appear.
logger
.
info
(
'Key on this new instance is %s'
%
new_key
)
logger
.
info
(
'Waiting for new main instance to be ready...'
)
new_ip
=
None
# Compare with original key. If same: success.
while
not
new_ip
or
new_ip
==
'None'
or
new_ip
==
ip
:
# XXX TODO
logger
.
info
(
'Not ready yet. SlapOS says main IP is %s'
%
new_ip
)
if
new_key
==
key
:
time
.
sleep
(
60
)
logger
.
info
(
'Success'
)
new_ip
=
fetchMainInstanceIP
(
partition
,
software
,
kvm_rootinstance_name
)
return
True
logger
.
info
(
'New IP of instance is %s'
%
new_ip
)
else
:
logger
.
error
(
'Failure'
)
new_key
=
fetchKey
(
new_ip
)
return
False
logger
.
info
(
'Key on this new instance is %s'
%
new_key
)
# Used if launched as standalone script
# Compare with original key. If same: success.
def
parseArguments
():
if
new_key
==
key
:
parser
=
argparse
.
ArgumentParser
()
logger
.
info
(
'Success for clone %s.'
%
current_clone
)
parser
.
add_argument
(
'--server-url'
,
type
=
str
)
else
:
parser
.
add_argument
(
'--key-file'
,
type
=
str
)
logger
.
info
(
'Failure for clone %s. Aborting.'
%
current_clone
)
parser
.
add_argument
(
'--cert-file'
,
type
=
str
)
return
False
parser
.
add_argument
(
'--computer-id'
,
type
=
str
)
parser
.
add_argument
(
'--partition-id'
,
type
=
str
)
# Setup "new old ip" for next clone, so that it will test it is different
parser
.
add_argument
(
'--software'
,
type
=
str
)
# from current clone
parser
.
add_argument
(
'--namebase'
,
type
=
str
)
ip
=
new_ip
parser
.
add_argument
(
'--kvm-rootinstance-name'
,
type
=
str
)
args
=
parser
.
parse_args
()
current_clone
=
current_clone
+
1
return
args
def
main
():
arguments
=
parseArguments
()
runTestCase
(
arguments
.
server_url
,
arguments
.
key_file
,
arguments
.
cert_file
,
arguments
.
computer_id
,
arguments
.
partition_id
,
arguments
.
software
,
arguments
.
namebase
,
arguments
.
kvm_rootinstance_name
)
if
__name__
==
'__main__'
:
main
()
# All clones have been successfully tested: success.
return
True
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment