Ejemplo n.º 1
0
    def test_updateService(self, client_mock):
        service = KubernetesService()
        client_mock.reset_mock()

        expected_body = V1Service(metadata=self._createMeta(self.name),
                                  spec=V1ServiceSpec(
                                      cluster_ip="None",
                                      ports=[
                                          V1ServicePort(name='mongod',
                                                        port=27017,
                                                        protocol='TCP')
                                      ],
                                      selector={
                                          'heritage': 'mongos',
                                          'name': self.name,
                                          'operated-by':
                                          'operators.ultimaker.com'
                                      },
                                  ))
        result = service.updateService(self.cluster_object)
        expected_calls = [
            call.CoreV1Api().patch_namespaced_service(self.name,
                                                      self.namespace,
                                                      expected_body)
        ]
        self.assertEqual(expected_calls, client_mock.mock_calls)
        self.assertEqual(
            client_mock.CoreV1Api().patch_namespaced_service.return_value,
            result)
Ejemplo n.º 2
0
    def test_updateService(self, client_mock):
        service = KubernetesService()
        client_mock.reset_mock()

        expected_body = V1Service(metadata=self._createMeta(self.name),
                                  spec=V1ServiceSpec(
                                      cluster_ip="None",
                                      ports=[
                                          V1ServicePort(name="mongod",
                                                        port=27017,
                                                        protocol="TCP")
                                      ],
                                      selector={
                                          "heritage": "mongos",
                                          "name": self.name,
                                          "operated-by":
                                          "operators.javamachr.cz"
                                      },
                                  ))
        result = service.updateService(self.cluster_object)
        expected_calls = [
            call.CoreV1Api().patch_namespaced_service(self.name,
                                                      self.namespace,
                                                      expected_body)
        ]
        self.assertEqual(expected_calls, client_mock.mock_calls)
        self.assertEqual(
            client_mock.CoreV1Api().patch_namespaced_service.return_value,
            result)