Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 75 lines (62 sloc) 1.931 kb
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
1 #!/usr/bin/env python
2
3 import pexpect
4 import sys
5 import os
bd8a550 time modified test
BuzzTroll authored
6 import datetime
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
7
f3cd495 @buzztroll breaking out the image name from the image location
buzztroll authored
8 tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
9 tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
899db05 @buzztroll this time remembering to quote the env
buzztroll authored
10 to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
11 cc_home=os.environ['CLOUD_CLIENT_HOME']
12 logfile = sys.stdout
13
f3cd495 @buzztroll breaking out the image name from the image location
buzztroll authored
14 src_file =tst_image_src
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
15 sfa = src_file.split("/")
16 image_name = sfa[len(sfa) - 1]
bd8a550 time modified test
BuzzTroll authored
17
18 upload_time = datetime.datetime.now()
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
19 cmd = "%s/bin/cloud-client.sh --transfer --sourcefile %s" % (cc_home, src_file)
20 (x, rc)=pexpect.run(cmd, withexitstatus=1)
21
22 cmd = "%s/bin/cloud-client.sh --list" % (cc_home)
b354f65 changing timeouts in cloud-client tests. NMI is exceeding
BuzzTroll authored
23 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
24 rc = child.expect (image_name)
25 if rc != 0:
26 print "%s not found in the list" % (image_name)
27 sys.exit(1)
28
29 line = child.readline()
bd8a550 time modified test
BuzzTroll authored
30 line = child.readline()
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
31 token = "Modified: "
32 ndx = line.find(token)
33 if ndx < 0:
34 print "%s not found in line %s" % (token, line)
35 sys.exit(1)
36 line = line[ndx + len(token):]
37 ndx = line.find("Size")
38 if ndx < 0:
39 print "%s not found in line %s" % (token, line)
40 sys.exit(1)
41 line = line[0:ndx].strip()
42
43 print "modified at %s" % (line)
44
bd8a550 time modified test
BuzzTroll authored
45 MONTHS = {"Jan" : 1, "Feb" : 2, "Mar" : 3, "Apr" : 4, "May" : 5, "Jun" : 6, "Jul" : 7, "Aug" : 8, "Sep" : 9, "Oct" : 10, "Nov" : 11, "Dec" : 12}
46 ndx = line.find(" ")
47 month = line[:ndx].strip()
48 m = MONTHS[month]
49 line = str(m) + " " + line[len(month):]
50 mod_time = datetime.datetime.strptime(line, "%m %d %Y @ %H:%M")
51
52 dt = abs(mod_time - upload_time)
53 if dt.seconds > 60:
54 print "The modification time presented may be wrong"
55 print mod_time
56 print upload_time
57 print dt
58 print dt.seconds
59 sys.exit(1)
60
61
9fd7575 adding new tests for cloud client list reporting
BuzzTroll authored
62 rc = child.expect(pexpect.EOF)
63 if rc != 0:
64 print "run"
65 sys.exit(1)
66
67 cmd = "%s/bin/cloud-client.sh --delete --name %s" % (cc_home, image_name)
68 print cmd
69 (x, rc)=pexpect.run(cmd, withexitstatus=1)
70 print x
71 if rc != 0:
72 print "failed to delete"
73 sys.exit(1)
74 sys.exit(0)
Something went wrong with that request. Please try again.