Пример #1
0
 def test_deleteStatefulSet(self, client_mock):
     service = KubernetesService()
     client_mock.reset_mock()
     result = service.deleteStatefulSet(self.name, self.namespace)
     expected_calls = [
         call.AppsV1beta1Api().delete_namespaced_stateful_set(
             self.name, self.namespace, V1DeleteOptions())
     ]
     self.assertEqual(expected_calls, client_mock.mock_calls)
     self.assertEqual(
         client_mock.AppsV1beta1Api().delete_namespaced_stateful_set.
         return_value, result)
Пример #2
0
    def test_updateStatefulSet(self, client_mock):
        service = KubernetesService()
        client_mock.reset_mock()

        result = service.updateStatefulSet(self.cluster_object)
        expected_calls = [
            call.AppsV1beta1Api().patch_namespaced_stateful_set(
                self.name, self.namespace, self.stateful_set)
        ]
        self.assertEqual(expected_calls, client_mock.mock_calls)
        self.assertEqual(
            client_mock.AppsV1beta1Api().patch_namespaced_stateful_set.
            return_value, result)
Пример #3
0
    def test_listAllStatefulSetsWithLabels_custom(self, client_mock):
        service = KubernetesService()
        client_mock.reset_mock()

        labels = {"operated-by": "me", "heritage": "mongo", "name": "name"}
        result = service.listAllStatefulSetsWithLabels(labels)
        expected_calls = [
            call.AppsV1beta1Api().list_stateful_set_for_all_namespaces(
                label_selector="operated-by=me,heritage=mongo,name=name")
        ]
        self.assertEqual(expected_calls, client_mock.mock_calls)
        self.assertEqual(
            client_mock.AppsV1beta1Api().list_stateful_set_for_all_namespaces.
            return_value, result)
Пример #4
0
    def test_listAllStatefulSetsWithLabels_default(self, client_mock):
        service = KubernetesService()
        client_mock.reset_mock()

        result = service.listAllStatefulSetsWithLabels()
        expected_calls = [
            call.AppsV1beta1Api().list_stateful_set_for_all_namespaces(
                label_selector=
                "operated-by=operators.ultimaker.com,heritage=mongos")
        ]
        self.assertEqual(expected_calls, client_mock.mock_calls)
        self.assertEqual(
            client_mock.AppsV1beta1Api().list_stateful_set_for_all_namespaces.
            return_value, result)
Пример #5
0
    def test___init__(self, client_mock):
        KubernetesService()
        config = Configuration()
        config.debug = False
        expected = [
            call.ApiClient(config),
            call.CoreV1Api(client_mock.ApiClient.return_value),
            call.CustomObjectsApi(client_mock.ApiClient.return_value),
            call.ApiextensionsV1beta1Api(client_mock.ApiClient.return_value),
            call.AppsV1beta1Api(client_mock.ApiClient.return_value),
        ]

        with patch("kubernetes.client.configuration.Configuration.__eq__",
                   dict_eq):
            self.assertEqual(expected, client_mock.mock_calls)
Пример #6
0
    def test_createStatefulSet_no_optional_fields(self, client_mock):
        service = KubernetesService()
        client_mock.reset_mock()
        del self.cluster_dict["spec"]["mongodb"]["cpu_limit"]
        del self.cluster_dict["spec"]["mongodb"]["memory_limit"]
        self.cluster_object = V1MongoClusterConfiguration(**self.cluster_dict)

        expected_calls = [
            call.AppsV1beta1Api().create_namespaced_stateful_set(
                self.namespace, self.stateful_set)
        ]

        result = service.createStatefulSet(self.cluster_object)
        self.assertEqual(expected_calls, client_mock.mock_calls)
        self.assertEqual(
            client_mock.AppsV1beta1Api().create_namespaced_stateful_set.
            return_value, result)