Example #1
0
    def test_no_op(self):
        self.clusters[0]["spec"]["id"] = "anid"
        self.clusters[0]["spec"]["external_id"] = "anotherid"
        current = {
            "cluster1": {
                "spec": self.clusters[0]["spec"],
                "network": self.clusters[0]["network"],
                "consoleUrl": "aconsoleurl",
                "serverUrl": "aserverurl",
                "elbFQDN": "anelbfqdn",
                "prometheusUrl": "aprometheusurl",
                "alertmanagerUrl": "analertmanagerurl",
            }
        }
        desired = deepcopy(current)
        current["cluster1"]["spec"].pop("initial_version")

        self.mock_callable(occ, "fetch_desired_state").to_return_value(
            desired).and_assert_called_once()
        self.mock_callable(
            occ.mr_client_gateway,
            "init").for_call(gitlab_project_id=None).to_return_value(
                "not a value").and_assert_called_once()
        self.mock_callable(self.ocmmap,
                           "cluster_specs").for_call().to_return_value(
                               (current, {})).and_assert_called_once()
        self.mock_callable(occ, "get_cluster_update_spec").to_return_value(
            ({}, False)).and_assert_called_once()
        with self.assertRaises(ValueError) as e:
            occ.run(False)
            self.assertEqual(e.args, (0, ))
Example #2
0
    def test_no_op(self):
        self.clusters[0]['spec']['id'] = 'anid'
        self.clusters[0]['spec']['external_id'] = 'anotherid'
        current = {
            'cluster1': {
                'spec': self.clusters[0]['spec'],
                'network': self.clusters[0]['network'],
                'consoleUrl': 'aconsoleurl',
                'serverUrl': 'aserverurl',
                'elbFQDN': 'anelbfqdn',
                'prometheusUrl': 'aprometheusurl',
                'alertmanagerUrl': 'analertmanagerurl',
            }
        }
        desired = deepcopy(current)
        current['cluster1']['spec'].pop('initial_version')

        self.mock_callable(occ, 'fetch_desired_state').to_return_value(
            desired
        ).and_assert_called_once()
        self.mock_callable(occ.mr_client_gateway, 'init').for_call(
            gitlab_project_id=None
        ).to_return_value('not a value').and_assert_called_once()
        self.mock_callable(
            self.ocmmap, 'cluster_specs'
        ).for_call().to_return_value(
            (current, {})
        ).and_assert_called_once()
        self.mock_callable(occ, 'get_cluster_update_spec').to_return_value(
            ({},  False)
        ).and_assert_called_once()
        with self.assertRaises(ValueError) as e:
            occ.run(False)
            self.assertEqual(e.args, (0, ))
Example #3
0
    def test_non_set_disable_uwm(self):
        current = {
            'cluster1': {
                'spec': self.clusters[0]['spec'],
                'network': self.clusters[0]['network'],
                'consoleUrl': 'aconsoleurl',
                'serverUrl': 'aserverurl',
                'elbFQDN': 'anelbfqdn',
                'prometheusUrl': 'aprometheusurl',
                'alertmanagerUrl': 'analertmanagerurl',
            }
        }
        self.clusters[0]['spec']['id'] = 'id'
        self.clusters[0]['spec']['external_id'] = 'ext_id'

        desired = deepcopy(current)
        self.clusters[0]['spec'][ocmmod.DISABLE_UWM_ATTR] = True

        self.mock_callable(occ, 'fetch_desired_state').to_return_value(
            desired
        ).and_assert_called_once()

        self.mock_callable(occ.mr_client_gateway, 'init').for_call(
            gitlab_project_id=None
        ).to_return_value('not a value').and_assert_called_once()

        self.mock_callable(
            self.ocmmap, 'cluster_specs'
        ).for_call().to_return_value((current, {})).and_assert_called_once()

        create_clusters_updates = StrictMock(
            clusters_updates.CreateClustersUpdates
        )
        self.mock_constructor(
            clusters_updates, 'CreateClustersUpdates'
        ).to_return_value(create_clusters_updates)

        self.mock_callable(
            create_clusters_updates, 'submit'
        ).for_call(cli='not a value').to_return_value(
            None).and_assert_called_once()

        with self.assertRaises(ValueError) as e:
            occ.run(False)
            self.assertEqual(e.args, (0, ))
Example #4
0
    def test_non_set_disable_uwm(self):
        current = {
            "cluster1": {
                "spec": self.clusters[0]["spec"],
                "network": self.clusters[0]["network"],
                "consoleUrl": "aconsoleurl",
                "serverUrl": "aserverurl",
                "elbFQDN": "anelbfqdn",
                "prometheusUrl": "aprometheusurl",
                "alertmanagerUrl": "analertmanagerurl",
            }
        }
        self.clusters[0]["spec"]["id"] = "id"
        self.clusters[0]["spec"]["external_id"] = "ext_id"

        desired = deepcopy(current)
        self.clusters[0]["spec"][ocmmod.DISABLE_UWM_ATTR] = True

        self.mock_callable(occ, "fetch_desired_state").to_return_value(
            desired).and_assert_called_once()

        self.mock_callable(
            occ.mr_client_gateway,
            "init").for_call(gitlab_project_id=None).to_return_value(
                "not a value").and_assert_called_once()

        self.mock_callable(self.ocmmap,
                           "cluster_specs").for_call().to_return_value(
                               (current, {})).and_assert_called_once()

        create_clusters_updates = StrictMock(
            clusters_updates.CreateClustersUpdates)
        self.mock_constructor(
            clusters_updates,
            "CreateClustersUpdates").to_return_value(create_clusters_updates)

        self.mock_callable(create_clusters_updates, "submit").for_call(
            cli="not a value").to_return_value(None).and_assert_called_once()

        with self.assertRaises(ValueError) as e:
            occ.run(False)
            self.assertEqual(e.args, (0, ))