Esempio n. 1
0
def test_get_started_apps_already_started_force_deploy():

        with patch('flow.utils.commons.print_msg') as mock_printmsg_fn:
            with patch.object(subprocess, 'Popen') as mocked_popen:
                mocked_popen.return_value.returncode = 0
                mocked_popen.return_value.communicate.return_value = (mock_started_apps_already_started.encode(), 'FAKE_ERR_OUTPUT')
                _b = MagicMock(BuildConfig)
                _b.project_name = 'CI-HelloWorld'
                _b.version_number = 'v2.9.0+1'
                _cf = CloudFoundry(_b)

                with patch.object(_cf, '_cf_logout'):
                    _cf._get_started_apps(True)
        mock_printmsg_fn.assert_any_call('CloudFoundry', '_get_started_apps', "Already found CI-HelloWorld-v2.9.0+1 but force_deploy turned on. Continuing with deployment.  Downtime will occur during deployment.")
Esempio n. 2
0
def test_get_started_apps_already_started_failed_cmd():

        with patch('flow.utils.commons.print_msg') as mock_printmsg_fn:
            with pytest.raises(SystemExit):
                with patch.object(subprocess, 'Popen') as mocked_popen:
                    mocked_popen.return_value.returncode = 1
                    mocked_popen.return_value.communicate.return_value = (mock_started_apps_already_started.encode(), 'FAKE_ERR_OUTPUT')
                    _b = MagicMock(BuildConfig)
                    _b.project_name = 'CI-HelloWorld'
                    _b.version_number = 'v2.9.0+1'
                    _cf = CloudFoundry(_b)

                    with patch.object(_cf, '_cf_logout'):
                        _cf._get_started_apps('true')
        mock_printmsg_fn.assert_any_call('CloudFoundry', '_get_started_apps', "Failed calling cf apps | grep CI-HelloWorld*-v\\d*\\.\\d*\\.\\d* | grep started | awk '{print $1}'. Return code of 1", 'ERROR')
Esempio n. 3
0
def test_get_started_apps_already_started():

        with patch('flow.utils.commons.print_msg') as mock_printmsg_fn:

            with patch.object(subprocess, 'Popen') as mocked_popen:
                with pytest.raises(SystemExit):
                    mocked_popen.return_value.returncode = 0
                    mocked_popen.return_value.communicate.return_value = (mock_started_apps_already_started.encode(),
                                                                          'FAKE_ERR_OUTPUT')
                    _b = MagicMock(BuildConfig)
                    _b.project_name = 'CI-HelloWorld'
                    _b.version_number = 'v2.9.0+1'
                    _cf = CloudFoundry(_b)

                    with patch.object(_cf, '_cf_logout'):
                        _cf._get_started_apps()

        mock_printmsg_fn.assert_any_call('CloudFoundry', '_get_started_apps', "App version CI-HelloWorld-v2.9.0+1 "
                                                                              "already exists and is running. Cannot "
                                                                              "perform zero-downtime deployment.  To "
                                                                              "override, set force flag = 'true'",
                                         'ERROR')