Add test upgrade StackLight. Minor changes

Change-Id: Ic863f65da4c36efd3bc5cb186e224d61cc7682ee
diff --git a/tcp_tests/managers/sl_manager.py b/tcp_tests/managers/sl_manager.py
index f65f524..1a97737 100644
--- a/tcp_tests/managers/sl_manager.py
+++ b/tcp_tests/managers/sl_manager.py
@@ -37,9 +37,8 @@
         super(SLManager, self).__init__(
             config=config, underlay=underlay)
 
-    def install(self, commands):
-        self.execute_commands(commands,
-                              label='Install SL services')
+    def install(self, commands, label='Install SL services'):
+        self.execute_commands(commands, label=label)
         self.__config.stack_light.sl_installed = True
         self.__config.stack_light.sl_vip_host = self.get_sl_vip()
 
diff --git a/tcp_tests/settings_oslo.py b/tcp_tests/settings_oslo.py
index 293e1cc..d42b444 100644
--- a/tcp_tests/settings_oslo.py
+++ b/tcp_tests/settings_oslo.py
@@ -224,6 +224,8 @@
 sl_opts = [
     ct.Cfg('sl_installed', ct.Boolean(),
            help="", default=False),
+    ct.Cfg('sl_version', ct.String(),
+           help="StackLight version. Could be 1 or 2", default=''),
     ct.Cfg('sl_vip_host', ct.IPAddress(),
            help="Vip address for SL services", default='0.0.0.0'),
     ct.Cfg('sl_prometheus_port', ct.String(),
diff --git a/tcp_tests/tests/system/test_upgrade_stacklight.py b/tcp_tests/tests/system/test_upgrade_stacklight.py
new file mode 100644
index 0000000..eec3fcd
--- /dev/null
+++ b/tcp_tests/tests/system/test_upgrade_stacklight.py
@@ -0,0 +1,69 @@
+#    Copyright 2016 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.
+
+from tcp_tests import logger
+from tcp_tests import settings
+import pytest
+LOG = logger.logger
+
+
+@pytest.mark.deploy
+class TestUpgradeStacklight(object):
+
+    """Test class for testing OpenContrail on a TCP lab"""
+    @pytest.mark.grab_versions
+    @pytest.mark.fail_snapshot
+    def test_upgrade_stacklight(self, underlay, config,
+                                hardware, sl_actions, sl_deployed):
+        """Runner
+
+        Scenario:
+            1. Prepare salt on hosts
+            2. Setup controller nodes
+            3. Setup compute nodes
+            4. Prepare tests
+            5. Run tests
+        """
+# Upgrade SL
+        lab_name = settings.LAB_CONFIG_NAME
+        steps_path = 'templates/{0}/sl-upgrade.yaml'.format(lab_name)
+        commands = underlay.read_template(steps_path)
+        sl_actions.install(commands, label='Upgrade SL services')
+        hardware.create_snapshot(name='sl_v1_upgraded')
+
+# Workaround for keepalived hang issue after env revert from snapshot
+# see https://mirantis.jira.com/browse/PROD-12038
+        LOG.warning('Restarting keepalived service on controllers...')
+        sl_actions._salt.local(tgt='ctl*', fun='cmd.run',
+                               args='systemctl restart keepalived.service')
+        LOG.warning('Restarting keepalived service on mon nodes...')
+        sl_actions._salt.local(tgt='mon*', fun='cmd.run',
+                               args='systemctl restart keepalived.service')
+
+        mon_nodes = sl_deployed.get_monitoring_nodes()
+        LOG.debug('Mon nodes list {0}'.format(mon_nodes))
+
+
+# Run SL component tetsts
+        sl_deployed.run_sl_functional_tests(
+            'cfg01',
+            '/root/stacklight-pytest/stacklight_tests/',
+            'tests',
+            'tests/prometheus')
+
+# Download report
+        sl_deployed.download_sl_test_report(
+            'cfg01',
+            '/root/stacklight-pytest/stacklight_tests/report.xml')
+        LOG.info("*************** DONE **************")