Add initial failover tests

* Warm restart of node by role
* Warm shutdown node by role
* Run func tests after fail

Need to do: assert test results for fails

Change-Id: I51934227340a60d5150e14f5004f2c3575264a36
diff --git a/tcp_tests/tests/system/test_failover.py b/tcp_tests/tests/system/test_failover.py
new file mode 100644
index 0000000..a8bb6b8
--- /dev/null
+++ b/tcp_tests/tests/system/test_failover.py
@@ -0,0 +1,205 @@
+#    Copyright 2017 Mirantis, Inc.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+import pytest
+
+from tcp_tests import logger
+
+LOG = logger.logger
+
+
+class TestFailover(object):
+    """Test class for testing OpenStack nodes failover"""
+
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_warm_shutdown_ctl01_node(self, underlay, openstack_deployed,
+                                      openstack_actions, show_step):
+        """Test warm shutdown ctl01
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute nodes
+            4. Shutdown ctl01
+            5. Run tempest smoke after failover
+
+
+        """
+        # STEP #1,2,3
+        show_step(1)
+        show_step(2)
+        show_step(3)
+        # STEP #4
+        show_step(4)
+        openstack_actions.warm_shutdown_openstack_nodes('ctl01')
+        # STEP #5
+        show_step(5)
+        openstack_actions.run_tempest(pattern='smoke')
+
+        LOG.info("*************** DONE **************")
+
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_restart_ctl01_node(self, underlay, openstack_deployed,
+                                      openstack_actions, show_step):
+        """Test restart ctl01
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute nodes
+            4. Restart ctl01
+            5. Run tempest smoke after failover
+
+
+        """
+        # STEP #1,2,3
+        show_step(1)
+        show_step(2)
+        show_step(3)
+
+        # STEP #4
+        show_step(4)
+        openstack_actions.warm_restart_nodes('ctl01')
+        # STEP #5
+        show_step(5)
+        openstack_actions.run_tempest(pattern='smoke')
+
+        LOG.info("*************** DONE **************")
+
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed,
+                                      openstack_actions, show_step):
+        """Test warm shutdown cmp01
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute nodes
+            4. Shutdown cmp01
+            5. Run tempest smoke after failover
+
+
+        """
+        # STEP #1,2,3
+        show_step(1)
+        show_step(2)
+        show_step(3)
+
+        # STEP #4
+        show_step(4)
+        openstack_actions.warm_shutdown_openstack_nodes('cmp01')
+        # STEP #5
+        show_step(5)
+        openstack_actions.run_tempest(pattern='smoke')
+
+        LOG.info("*************** DONE **************")
+
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_restart_cmp01_node(self, underlay, openstack_deployed,
+                                openstack_actions, show_step):
+        """Test restart cmp01
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute nodes
+            4. Restart cmp01
+            5. Run tempest smoke after failover
+
+
+        """
+        # STEP #1,2,3
+        show_step(1)
+        show_step(2)
+        show_step(3)
+
+        # STEP #4
+        show_step(4)
+        openstack_actions.warm_restart_nodes('cmp01')
+        # STEP #5
+        show_step(5)
+        openstack_actions.run_tempest(pattern='smoke')
+
+        LOG.info("*************** DONE **************")
+
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_restart_mon01_node(self, underlay, openstack_deployed,
+                                openstack_actions, sl_deployed,
+                                show_step):
+        """Test restart mon01
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute, monitoring nodes
+            4. Restart mon01
+            5. Run LMA smoke after failover
+
+
+        """
+        # STEP #1,2,3
+        show_step(1)
+        show_step(2)
+        show_step(3)
+
+        # STEP #4
+        show_step(4)
+        openstack_actions.warm_restart_nodes('mon01')
+        # STEP #5
+        show_step(5)
+        # Run SL component tetsts
+        sl_deployed.run_sl_functional_tests(
+            'cfg01',
+            '/root/stacklight-pytest/stacklight_tests/',
+            'tests/prometheus/test_smoke.py',
+            'test_alerts.py')
+        LOG.info("*************** DONE **************")
+
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_warm_shutdown_mon01_node(self, underlay, openstack_deployed,
+                                      openstack_actions, sl_deployed,
+                                      show_step):
+        """Test warm shutdown mon01
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute, monitoring nodes
+            4. Shutdown mon01
+            5. Run LMA smoke after failover
+
+
+        """
+        # STEP #1,2,3
+        show_step(1)
+        show_step(2)
+        show_step(3)
+
+        # STEP #4
+        show_step(4)
+        openstack_actions.warm_shutdown_openstack_nodes('mon01')
+        # STEP #5
+        show_step(5)
+        sl_deployed.run_sl_functional_tests(
+            'cfg01',
+            '/root/stacklight-pytest/stacklight_tests/',
+            'tests/prometheus/test_smoke.py',
+            'test_alerts.py')
+        LOG.info("*************** DONE **************")