3 from mgr_test_case import MgrTestCase
9 log = logging.getLogger(__name__)
12 class TestDashboard(MgrTestCase):
15 def test_standby(self):
16 self._assign_ports("dashboard", "server_port")
17 self._load_module("dashboard")
19 original_active = self.mgr_cluster.get_active_id()
21 original_uri = self._get_uri("dashboard")
22 log.info("Originally running at {0}".format(original_uri))
24 self.mgr_cluster.mgr_fail(original_active)
26 failed_over_uri = self._get_uri("dashboard")
27 log.info("After failover running at {0}".format(original_uri))
29 self.assertNotEqual(original_uri, failed_over_uri)
31 # The original active daemon should have come back up as a standby
32 # and be doing redirects to the new active daemon
33 r = requests.get(original_uri, allow_redirects=False)
34 self.assertEqual(r.status_code, 303)
35 self.assertEqual(r.headers['Location'], failed_over_uri)
38 self._assign_ports("dashboard", "server_port")
39 self._load_module("dashboard")
41 base_uri = self._get_uri("dashboard")
43 # This is a very simple smoke test to check that the dashboard can
44 # give us a 200 response to requests. We're not testing that
45 # the content is correct or even renders!
59 r = requests.get(base_uri + url, allow_redirects=False)
60 if r.status_code >= 300 and r.status_code < 400:
61 log.error("Unexpected redirect to: {0} (from {1})".format(
62 r.headers['Location'], base_uri))
63 if r.status_code != 200:
66 log.info("{0}: {1} ({2} bytes)".format(
67 url, r.status_code, len(r.content)
70 self.assertListEqual(failures, [])