Change ordering of ceilometer service startup

If the compute-agent starts before the collector directly
after a start or restart of the AMQP service, samples published from
the compute-agent can be lost before the collector has had a chance
to establish connections. These lost samples impact the reliability
of tests which run immediately after the service [re]start.

Note: if there is a restart of the ceilo service, but not the AMQP
service, the problem does not present itself becaue the messaging
service maintains some state on the exchanges it keeps.

Change-Id: I1c06d0511fbf93050cda56d9d2de0ff00813dfb6
Closes-bug: 1355809
diff --git a/lib/ceilometer b/lib/ceilometer
index 54d95c5..7bd1421 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -223,16 +223,19 @@
 
 # start_ceilometer() - Start running processes, including screen
 function start_ceilometer {
+    screen_it ceilometer-acentral "cd ; ceilometer-agent-central --config-file $CEILOMETER_CONF"
+    screen_it ceilometer-anotification "cd ; ceilometer-agent-notification --config-file $CEILOMETER_CONF"
+    screen_it ceilometer-collector "cd ; ceilometer-collector --config-file $CEILOMETER_CONF"
+    screen_it ceilometer-api "cd ; ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR --config-file $CEILOMETER_CONF"
+
+    # Start the compute agent last to allow time for the collector to
+    # fully wake up and connect to the message bus. See bug #1355809
     if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then
         screen_it ceilometer-acompute "cd ; sg $LIBVIRT_GROUP 'ceilometer-agent-compute --config-file $CEILOMETER_CONF'"
     fi
     if [[ "$VIRT_DRIVER" = 'vsphere' ]]; then
         screen_it ceilometer-acompute "cd ; ceilometer-agent-compute --config-file $CEILOMETER_CONF"
     fi
-    screen_it ceilometer-acentral "cd ; ceilometer-agent-central --config-file $CEILOMETER_CONF"
-    screen_it ceilometer-anotification "cd ; ceilometer-agent-notification --config-file $CEILOMETER_CONF"
-    screen_it ceilometer-collector "cd ; ceilometer-collector --config-file $CEILOMETER_CONF"
-    screen_it ceilometer-api "cd ; ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR --config-file $CEILOMETER_CONF"
 
     # only die on API if it was actually intended to be turned on
     if is_service_enabled ceilometer-api; then