def test_start_serving_bundle(self): """ Test actually serving a deployed bundle, then taking it down. """ self.install_my_bundle() (instance_id, node_name, host_ip, host_port) = \ deploy.start_serving_bundle(self.app_id, self.bundle_name) self.assertTrue(isinstance(instance_id, str)) self.assertTrue(isinstance(node_name, str)) self.assertTrue(isinstance(host_ip, str)) self.assertTrue(isinstance(host_port, int)) app_url = "http://%s:%d" % (host_ip, host_port) self.check_can_eventually_load( app_url, "Welcome to the Django tutorial polls app") # we shouldn't be able to serve the same bundle again from this # appserver with self.assertRaises(utils.InfrastructureException): deploy.start_serving_bundle(self.app_id, self.bundle_name) num_stopped = deploy.stop_serving_bundle(self.app_id, self.bundle_name) self.assertEqual(num_stopped, 1) with self.assertRaises(IOError): urllib.urlopen(app_url).read()
def tearDown(self): """Ensure the test bundle is no longer served, cleaning up this bundle from /etc/supervisor/conf.d.""" num_stopped = deploy.stop_serving_bundle(self.app_id, self.bundle_name) print "tearDown stopped instances: %d" % num_stopped