This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
cc-prop2-test.py
executable file
·60 lines (53 loc) · 1.65 KB
/
cc-prop2-test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
import pexpect
import sys
import os
import filecmp
import uuid
tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
cc_home=os.environ['CLOUD_CLIENT_HOME']
logfile = sys.stdout
newname=str(uuid.uuid1()).replace("-", "")
try:
os.remove(newname)
except:
pass
cmd = "%s/bin/cloud-client.sh --transfer --sourcefile %s" % (cc_home, tst_image_src)
(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
cmd = "%s/bin/cloud-client.sh --run --name %s --hours .25" % (cc_home, tst_image_name)
child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
rc = child.expect ('Running:')
if rc != 0:
print "%s not found in the list" % (tst_image_name)
sys.exit(1)
handle = child.readline().strip().replace("'", "")
rc = child.expect(pexpect.EOF)
if rc != 0:
print "run"
sys.exit(1)
cmd = "%s/bin/cloud-client.sh --handle %s --save --newname %s" % (cc_home, handle, newname)
print cmd
(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
print "failed to save"
sys.exit(1)
cmd = "%s/bin/cloud-client.sh --list" % (cc_home)
(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
cmd = "%s/bin/cloud-client.sh --download --name %s --localfile %s" % (cc_home, newname, newname)
print cmd
(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
print "failed to terminate"
sys.exit(1)
rc = filecmp.cmp(newname, tst_image_src)
os.remove(newname)
if rc:
sys.exit(0)
else:
print "files differ"
sys.exit(1)
sys.exit(0)