36
37
def on_message(msg):
37
38
log.info('on_message: %s', msg.body)
38
39
params = json.loads(msg.body)
40
# We use the progress_trigger for both the progress queue and to define the
41
# container in the data store.
39
42
progress_queue = params['progress_trigger']
40
43
image_id = params['image_id']
41
44
package_list = params['package_list']
44
47
def status_cb(msg):
45
48
amqp_utils.progress_update(progress_queue, {'message': msg})
50
# The tests will succeed unless they fail ;)
47
51
notify = amqp_utils.progress_completed
54
store = data_store.DataStore(
55
'test-runner', tstrun.get_auth_config(),
56
identifier=params['progress_trigger'], public=True)
50
57
# FIXME: We need either a config option or a parameter for the instance
51
58
# flavor -- vila 2014-01-29
52
59
flavor = 'm1.small'
63
70
status_cb('testing %s' % package)
64
71
# uci-vms shell adt-run ... --- adt-virt-null
65
72
return_code, subunit_stream = test_bed.run_test(package)
66
# uci-vms shell collect_artifacts and test results
67
results[package] = (return_code, subunit_stream)
73
# uci-vms shell collect test results
74
subunit_url = store.put_file('{}-subunit-stream'.format(package),
76
results[package] = subunit_url
68
77
# 0 is success, 8 is skipped and considered a success
69
78
if return_code not in (0, 8):
79
# At least one test failed
70
80
notify = amqp_utils.progress_failed
71
notify(progress_queue, results)
72
81
except Exception as e:
82
# FIXME: 'message' ??? Is the lander expecting that ? Needs testing --
73
84
results['message'] = str(e)
74
85
notify = amqp_utils.progress_failed
76
# remove from queue so request becomes completed
87
# All tests have been run, report success or failure
88
notify(progress_queue, results)
89
# Request completed, remove from queue
91
# FIXME: There is still a hole somewhere, the ack below won't happen if
92
# an exception occurs while calling 'notify' just above, tricky testing
93
# ahead... -- vila 2014-02-06
77
94
msg.channel.basic_ack(msg.delivery_tag)
79
notify(progress_queue, results)
80
95
test_bed.teardown()