Beispiel #1
0
def get_mpack_properties():
    """
  Read ambari properties required for management packs
  :return: (stack_location, service_definitions_location, mpacks_staging_location)
  """
    # Get ambari config properties
    properties = get_ambari_properties()
    if properties == -1:
        print_error_msg("Error getting ambari properties")
        return -1
    stack_location = get_stack_location(properties)
    extension_location = get_extension_location(properties)
    service_definitions_location = get_common_services_location(properties)
    mpacks_staging_location = get_mpacks_staging_location(properties)
    dashboard_location = get_dashboard_location(properties)
    ambari_version = get_ambari_version(properties)
    return stack_location, extension_location, service_definitions_location, mpacks_staging_location, dashboard_location
Beispiel #2
0
    def test_install_addon_service_mpack(
            self, download_mpack_mock, expand_mpack_mock,
            purge_stacks_and_mpacks_mock, add_replay_log_mock,
            get_ambari_properties_mock, get_ambari_version_mock,
            create_symlink_mock, os_mkdir_mock, shutil_move_mock,
            os_symlink_mock, os_path_isdir_mock, os_path_exists_mock):
        options = self._create_empty_options_mock()
        options.mpack_path = "/path/to/myservice.tar.gz"
        options.purge = False
        download_mpack_mock.return_value = "/tmp/myservice.tar.gz"
        expand_mpack_mock.return_value = "mpacks/myservice-ambari-mpack-1.0.0.0"
        get_ambari_version_mock.return_value = "2.4.0.0"

        os_path_exists_mock.side_effect = [
            True, True, True, True, True, True, True, True, False, False,
            False, False, True, True, True, False, True, True, True, False
        ]

        get_ambari_properties_mock.return_value = configs
        shutil_move_mock.return_value = True
        os_path_isdir_mock.return_value = True

        install_mpack(options)

        stacks_directory = configs[serverConfiguration.STACK_LOCATION_KEY]
        common_services_directory = configs[
            serverConfiguration.COMMON_SERVICES_PATH_PROPERTY]
        mpacks_directory = configs[
            serverConfiguration.MPACKS_STAGING_PATH_PROPERTY]
        mpacks_staging_directory = os.path.join(
            mpacks_directory, "myservice-ambari-mpack-1.0.0.0")
        dashboards_directory = serverConfiguration.get_dashboard_location(
            configs)

        os_path_exists_calls = [
            call('/tmp/myservice.tar.gz'),
            call('mpacks/myservice-ambari-mpack-1.0.0.0/mpack.json'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0'),
            call('/var/lib/ambari-server/resources/stacks'),
            call('/var/lib/ambari-server/resources/extensions'),
            call('/var/lib/ambari-server/resources/common-services'),
            call(mpacks_directory),
            call(mpacks_directory + '/cache'),
            call('/var/lib/ambari-server/resources/dashboards'),
            call(mpacks_directory + '/myservice-ambari-mpack-1.0.0.0'),
            call('/var/lib/ambari-server/resources/common-services/MYSERVICE'),
            call(
                mpacks_directory +
                '/myservice-ambari-mpack-1.0.0.0/common-services/MYSERVICE/1.0.0/dashboards'
            ),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0/services'
                 ),
            call(
                mpacks_directory +
                '/myservice-ambari-mpack-1.0.0.0/custom-services/MYSERVICE/1.0.0/dashboards'
            ),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/2.0'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/2.0/services'
                 ),
            call(
                mpacks_directory +
                '/myservice-ambari-mpack-1.0.0.0/custom-services/MYSERVICE/2.0.0/dashboards'
            )
        ]

        os_mkdir_calls = [
            call(dashboards_directory),
            call(os.path.join(dashboards_directory,
                              GRAFANA_DASHBOARDS_DIRNAME)),
            call(os.path.join(dashboards_directory, SERVICE_METRICS_DIRNAME)),
            call(os.path.join(common_services_directory, "MYSERVICE"))
        ]
        create_symlink_calls = [
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/MYSERVICE"),
                os.path.join(common_services_directory, "MYSERVICE"), "1.0.0",
                None)
        ]
        os_symlink_calls = [
            call(
                os.path.join(mpacks_staging_directory,
                             "custom-services/MYSERVICE/1.0.0"),
                os.path.join(stacks_directory,
                             "MYSTACK/1.0/services/MYSERVICE")),
            call(
                os.path.join(mpacks_staging_directory,
                             "custom-services/MYSERVICE/2.0.0"),
                os.path.join(stacks_directory,
                             "MYSTACK/2.0/services/MYSERVICE"))
        ]

        os_path_exists_mock.assert_has_calls(os_path_exists_calls)
        self.assertFalse(purge_stacks_and_mpacks_mock.called)
        os_mkdir_mock.assert_has_calls(os_mkdir_calls)
        create_symlink_mock.assert_has_calls(create_symlink_calls)
        os_symlink_mock.assert_has_calls(os_symlink_calls)
        self.assertTrue(add_replay_log_mock.called)
Beispiel #3
0
    def test_upgrade_stack_mpack(
            self, run_os_command_mock, download_mpack_mock, expand_mpack_mock,
            purge_stacks_and_mpacks_mock, _uninstall_mpack_mock,
            add_replay_log_mock, get_ambari_properties_mock,
            get_ambari_version_mock, create_symlink_mock, os_mkdir_mock,
            shutil_move_mock, os_path_exists_mock,
            create_symlink_using_path_mock):
        options = self._create_empty_options_mock()
        options.mpack_path = "/path/to/mystack-1.0.0.1.tar.gz"
        download_mpack_mock.side_effect = [
            "/tmp/mystack-1.0.0.1.tar.gz", "/tmp/mystack-1.0.0.1.tar.gz"
        ]
        expand_mpack_mock.side_effect = [
            "mpacks/mystack-ambari-mpack-1.0.0.1",
            "mpacks/mystack-ambari-mpack-1.0.0.1"
        ]
        get_ambari_version_mock.return_value = "2.4.0.0"
        run_os_command_mock.return_value = (0, "", "")
        mpacks_directory = configs[
            serverConfiguration.MPACKS_STAGING_PATH_PROPERTY]
        os_path_exists_mock.side_effect = [
            True, True, True, True, True, True, True, True, True, True, True,
            True, True, True, True, False, False, True, False, False, True,
            False, False, False, False, False, True, True, True, False, True,
            True, False, True, True, False, False, False, False, False, True,
            True, True, True, True, True, True, False, True, False, True, True,
            True, True, True, True
        ]
        get_ambari_properties_mock.return_value = configs
        shutil_move_mock.return_value = True

        upgrade_mpack(options)

        stacks_directory = configs[serverConfiguration.STACK_LOCATION_KEY]
        common_services_directory = configs[
            serverConfiguration.COMMON_SERVICES_PATH_PROPERTY]
        mpacks_directory = configs[
            serverConfiguration.MPACKS_STAGING_PATH_PROPERTY]
        mpacks_staging_directory = os.path.join(
            mpacks_directory, "mystack-ambari-mpack-1.0.0.1")
        dashboards_directory = serverConfiguration.get_dashboard_location(
            configs)

        os_path_exists_calls = [
            call('/tmp/mystack-1.0.0.1.tar.gz'),
            call('mpacks/mystack-ambari-mpack-1.0.0.1/mpack.json'),
            call(mpacks_directory),
            call(mpacks_directory +
                 '/myextension-ambari-mpack-1.0.0.0/mpack.json'),
            call(mpacks_directory +
                 '/myservice-ambari-mpack-1.0.0.0/mpack.json'),
            call(mpacks_directory +
                 '/mystack-ambari-mpack-1.0.0.0/mpack.json'),
            call(mpacks_directory +
                 '/mystack-ambari-mpack-1.0.0.1/mpack.json'),
            call('/tmp/mystack-1.0.0.1.tar.gz'),
            call('mpacks/mystack-ambari-mpack-1.0.0.1/mpack.json'),
            call(
                'mpacks/mystack-ambari-mpack-1.0.0.1/hooks/before_upgrade.py'),
            call('/var/lib/ambari-server/resources/stacks'),
            call('/var/lib/ambari-server/resources/extensions'),
            call('/var/lib/ambari-server/resources/common-services'),
            call(mpacks_directory),
            call(mpacks_directory + '/cache'),
            call('/var/lib/ambari-server/resources/dashboards'),
            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.1'),
            call('/var/lib/ambari-server/resources/common-services/SERVICEA'),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/common-services/SERVICEA/1.0/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/common-services/SERVICEA/2.0/dashboards'
            ),
            call('/var/lib/ambari-server/resources/common-services/SERVICEB'),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/common-services/SERVICEB/1.0.0/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/common-services/SERVICEB/2.0.0/dashboards'
            ),
            call('/var/lib/ambari-server/resources/common-services/SERVICEC'),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/common-services/SERVICEC/1.0.0/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/common-services/SERVICEC/2.0.0/dashboards'
            ),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0/services'
                 ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/1.0/services/SERVICEA/dashboards'
            ),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.1'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.1/services'
                 ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/1.1/services/SERVICEA/dashboards'
            ),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/2.0'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/2.0/services'
                 ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/2.0/services/SERVICEA/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/2.0/services/SERVICEB/dashboards'
            ),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/3.0'),
            call('/var/lib/ambari-server/resources/stacks/MYSTACK/3.0/services'
                 ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEA/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEB/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEB/dashboards/grafana-dashboards'
            ),
            call(
                '/var/lib/ambari-server/resources/dashboards/grafana-dashboards/SERVICEB'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEB/dashboards/service-metrics/SERVICEB.txt'
            ),
            call(
                '/var/lib/ambari-server/resources/dashboards/service-metrics/SERVICEB.txt'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEC/dashboards'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEC/dashboards/grafana-dashboards'
            ),
            call(
                '/var/lib/ambari-server/resources/dashboards/grafana-dashboards/SERVICEC'
            ),
            call(
                mpacks_directory +
                '/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEC/dashboards/service-metrics/SERVICEC.txt'
            ),
            call(
                '/var/lib/ambari-server/resources/dashboards/service-metrics/SERVICEC.txt'
            ),
            call(mpacks_directory),
            call(mpacks_directory +
                 '/myextension-ambari-mpack-1.0.0.0/mpack.json'),
            call(mpacks_directory +
                 '/myservice-ambari-mpack-1.0.0.0/mpack.json'),
            call(mpacks_directory +
                 '/mystack-ambari-mpack-1.0.0.0/mpack.json'),
            call(mpacks_directory +
                 '/mystack-ambari-mpack-1.0.0.1/mpack.json'),
            call(mpacks_directory +
                 '/mystack-ambari-mpack-1.0.0.1/hooks/after_upgrade.py')
        ]

        run_os_command_calls = [
            call([
                "/usr/bin/ambari-python-wrap",
                "mpacks/mystack-ambari-mpack-1.0.0.1/hooks/before_upgrade.py"
            ]),
            call([
                "/usr/bin/ambari-python-wrap", mpacks_directory +
                "/mystack-ambari-mpack-1.0.0.1/hooks/after_upgrade.py"
            ])
        ]

        os_mkdir_calls = [
            call(dashboards_directory),
            call(os.path.join(dashboards_directory,
                              GRAFANA_DASHBOARDS_DIRNAME)),
            call(os.path.join(dashboards_directory, SERVICE_METRICS_DIRNAME)),
            call(os.path.join(common_services_directory, "SERVICEC")),
            call(os.path.join(stacks_directory, "MYSTACK/3.0")),
            call(os.path.join(stacks_directory, "MYSTACK/3.0/services"))
        ]
        create_symlink_calls = [
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEA"),
                os.path.join(common_services_directory, "SERVICEA"), "1.0",
                True),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEA"),
                os.path.join(common_services_directory, "SERVICEA"), "2.0",
                True),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEB"),
                os.path.join(common_services_directory, "SERVICEB"), "1.0.0",
                True),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEB"),
                os.path.join(common_services_directory, "SERVICEB"), "2.0.0",
                True),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEC"),
                os.path.join(common_services_directory, "SERVICEC"), "1.0.0",
                True),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEC"),
                os.path.join(common_services_directory, "SERVICEC"), "2.0.0",
                True),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/1.0"),
                 os.path.join(stacks_directory, "MYSTACK/1.0"), "metainfo.xml",
                 True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/1.0/services"),
                os.path.join(stacks_directory, "MYSTACK/1.0/services"),
                "SERVICEA", True),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/1.1"),
                 os.path.join(stacks_directory, "MYSTACK/1.1"), "metainfo.xml",
                 True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/1.1/services"),
                os.path.join(stacks_directory, "MYSTACK/1.1/services"),
                "SERVICEA", True),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/2.0"),
                 os.path.join(stacks_directory, "MYSTACK/2.0"), "metainfo.xml",
                 True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/2.0/services"),
                os.path.join(stacks_directory, "MYSTACK/2.0/services"),
                "SERVICEA", True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/2.0/services"),
                os.path.join(stacks_directory, "MYSTACK/2.0/services"),
                "SERVICEB", True),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/3.0"),
                 os.path.join(stacks_directory, "MYSTACK/3.0"), "metainfo.xml",
                 True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/3.0/services"),
                os.path.join(stacks_directory, "MYSTACK/3.0/services"),
                "SERVICEA", True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/3.0/services"),
                os.path.join(stacks_directory, "MYSTACK/3.0/services"),
                "SERVICEB", True),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/3.0/services"),
                os.path.join(stacks_directory, "MYSTACK/3.0/services"),
                "SERVICEC", True),
            call(
                os.path.join(
                    mpacks_staging_directory,
                    "stacks/MYSTACK/3.0/services/SERVICEC/dashboards/service-metrics"
                ), os.path.join(dashboards_directory, "service-metrics"),
                "SERVICEC.txt", True)
        ]

        create_symlink_using_path_calls = [
            call(
                os.path.join(
                    mpacks_staging_directory,
                    "stacks/MYSTACK/3.0/services/SERVICEC/dashboards/grafana-dashboards"
                ),
                os.path.join(dashboards_directory,
                             "grafana-dashboards/SERVICEC"), True)
        ]

        os_path_exists_mock.assert_has_calls(os_path_exists_calls)
        self.assertFalse(purge_stacks_and_mpacks_mock.called)
        run_os_command_mock.assert_has_calls(run_os_command_calls)
        os_mkdir_mock.assert_has_calls(os_mkdir_calls)
        create_symlink_mock.assert_has_calls(create_symlink_calls)
        self.assertEqual(18, create_symlink_mock.call_count)
        create_symlink_using_path_mock.assert_has_calls(
            create_symlink_using_path_calls)
        self.assertEqual(1, create_symlink_using_path_mock.call_count)
        _uninstall_mpack_mock.assert_has_calls(
            [call("mystack-ambari-mpack", "1.0.0.0")])
        self.assertTrue(add_replay_log_mock.called)
Beispiel #4
0
    def test_install_stack_mpack(
            self, validate_purge_mock, run_os_command_mock,
            download_mpack_mock, expand_mpack_mock,
            purge_stacks_and_mpacks_mock, add_replay_log_mock,
            get_ambari_properties_mock, get_ambari_version_mock,
            create_symlink_mock, os_mkdir_mock, shutil_move_mock,
            os_path_exists_mock):
        options = self._create_empty_options_mock()
        options.mpack_path = "/path/to/mystack.tar.gz"
        options.purge = True
        download_mpack_mock.return_value = "/tmp/mystack.tar.gz"
        expand_mpack_mock.return_value = "mpacks/mystack-ambari-mpack-1.0.0.0"
        get_ambari_version_mock.return_value = "2.4.0.0"
        run_os_command_mock.return_value = (0, "", "")
        mpacks_directory = configs[
            serverConfiguration.MPACKS_STAGING_PATH_PROPERTY]
        """
    os_path_exists_calls = [call('/tmp/mystack.tar.gz'),
                            call('mpacks/mystack-ambari-mpack-1.0.0.0/mpack.json'),
                            call('mpacks/mystack-ambari-mpack-1.0.0.0/hooks/before_install.py'),
                            call('/var/lib/ambari-server/resources/stacks'),
                            call('/var/lib/ambari-server/resources/extensions'),
                            call('/var/lib/ambari-server/resources/common-services'),
                            call(mpacks_directory),
                            call(mpacks_directory + '/cache'),
                            call('/var/lib/ambari-server/resources/dashboards'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0'),
                            call('/var/lib/ambari-server/resources/common-services/SERVICEA'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/common-services/SERVICEA/1.0/dashboards'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/common-services/SERVICEA/2.0/dashboards'),
                            call('/var/lib/ambari-server/resources/common-services/SERVICEB'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/common-services/SERVICEB/1.0.0/dashboards'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/common-services/SERVICEB/2.0.0/dashboards'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.0/services'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/stacks/MYSTACK/1.0/services/SERVICEA/dashboards'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.1'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK/1.1/services'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/stacks/MYSTACK/1.1/services/SERVICEA/dashboards'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK/2.0'),
                            call('/var/lib/ambari-server/resources/stacks/MYSTACK/2.0/services'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/stacks/MYSTACK/2.0/services/SERVICEA/dashboards'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/stacks/MYSTACK/2.0/services/SERVICEB/dashboards'),
                            call(mpacks_directory + '/mystack-ambari-mpack-1.0.0.0/hooks/after_install.py')]
    """
        os_path_exists_mock.side_effect = [
            True, True, True, False, True, False, False, False, False, False,
            False, False, False, False, False, False, False, False, False,
            False, False, False, False, False, False, False, False, True
        ]
        get_ambari_properties_mock.return_value = configs
        shutil_move_mock.return_value = True

        install_mpack(options)

        stacks_directory = configs[serverConfiguration.STACK_LOCATION_KEY]
        common_services_directory = configs[
            serverConfiguration.COMMON_SERVICES_PATH_PROPERTY]
        extensions_directory = configs[
            serverConfiguration.EXTENSION_PATH_PROPERTY]
        mpacks_directory = configs[
            serverConfiguration.MPACKS_STAGING_PATH_PROPERTY]
        dashboards_directory = serverConfiguration.get_dashboard_location(
            configs)
        mpacks_staging_directory = os.path.join(
            mpacks_directory, "mystack-ambari-mpack-1.0.0.0")

        run_os_command_calls = [
            call([
                "/usr/bin/ambari-python-wrap",
                "mpacks/mystack-ambari-mpack-1.0.0.0/hooks/before_install.py"
            ]),
            call([
                "/usr/bin/ambari-python-wrap", mpacks_directory +
                "/mystack-ambari-mpack-1.0.0.0/hooks/after_install.py"
            ])
        ]

        os_mkdir_calls = [
            call(stacks_directory),
            call(common_services_directory),
            call(mpacks_directory),
            call(mpacks_directory + '/cache'),
            call(dashboards_directory),
            call(os.path.join(dashboards_directory,
                              GRAFANA_DASHBOARDS_DIRNAME)),
            call(os.path.join(dashboards_directory, SERVICE_METRICS_DIRNAME)),
            call(os.path.join(common_services_directory, "SERVICEA")),
            call(os.path.join(common_services_directory, "SERVICEB")),
            call(os.path.join(stacks_directory, "MYSTACK")),
            call(os.path.join(stacks_directory, "MYSTACK/1.0")),
            call(os.path.join(stacks_directory, "MYSTACK/1.0/services")),
            call(os.path.join(stacks_directory, "MYSTACK/1.1")),
            call(os.path.join(stacks_directory, "MYSTACK/1.1/services")),
            call(os.path.join(stacks_directory, "MYSTACK/2.0")),
            call(os.path.join(stacks_directory, "MYSTACK/2.0/services"))
        ]
        create_symlink_calls = [
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEA"),
                os.path.join(common_services_directory, "SERVICEA"), "1.0",
                None),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEA"),
                os.path.join(common_services_directory, "SERVICEA"), "2.0",
                None),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEB"),
                os.path.join(common_services_directory, "SERVICEB"), "1.0.0",
                None),
            call(
                os.path.join(mpacks_staging_directory,
                             "common-services/SERVICEB"),
                os.path.join(common_services_directory, "SERVICEB"), "2.0.0",
                None),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/1.0"),
                 os.path.join(stacks_directory, "MYSTACK/1.0"), "metainfo.xml",
                 None),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/1.0/services"),
                os.path.join(stacks_directory, "MYSTACK/1.0/services"),
                "SERVICEA", None),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/1.1"),
                 os.path.join(stacks_directory, "MYSTACK/1.1"), "metainfo.xml",
                 None),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/1.1/services"),
                os.path.join(stacks_directory, "MYSTACK/1.1/services"),
                "SERVICEA", None),
            call(os.path.join(mpacks_staging_directory, "stacks/MYSTACK/2.0"),
                 os.path.join(stacks_directory, "MYSTACK/2.0"), "metainfo.xml",
                 None),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/2.0/services"),
                os.path.join(stacks_directory, "MYSTACK/2.0/services"),
                "SERVICEA", None),
            call(
                os.path.join(mpacks_staging_directory,
                             "stacks/MYSTACK/2.0/services"),
                os.path.join(stacks_directory, "MYSTACK/2.0/services"),
                "SERVICEB", None)
        ]

        self.assertTrue(purge_stacks_and_mpacks_mock.called)
        run_os_command_mock.assert_has_calls(run_os_command_calls)
        os_mkdir_mock.assert_has_calls(os_mkdir_calls)
        create_symlink_mock.assert_has_calls(create_symlink_calls)
        self.assertTrue(add_replay_log_mock.called)