예제 #1
0
 def test_get_by_labels_invalid_args(self):
     name = object()
     try:
         K8sPod.get_by_labels(labels=name)
         self.fail("Should not fail.")
     except Exception as err:
         self.assertIsInstance(err, SyntaxError)
예제 #2
0
 def test_get_by_labels_nonexistent(self):
     name = "yopod-{0}".format(str(uuid.uuid4()))
     config = K8sConfig(kubeconfig=utils.kubeconfig_fallback)
     if utils.is_reachable(config.api_host):
         pods = K8sPod.get_by_labels(config=config, labels={'name': name})
         self.assertIsInstance(pods, list)
         self.assertEqual(0, len(pods))
예제 #3
0
 def test_get_by_labels_nonexistent(self):
     name = "yopod-{0}".format(str(uuid.uuid4()))
     config = K8sConfig(kubeconfig=utils.kubeconfig_fallback)
     if utils.is_reachable(config.api_host):
         pods = K8sPod.get_by_labels(config=config, labels={'name': name})
         self.assertIsInstance(pods, list)
         self.assertEqual(0, len(pods))
예제 #4
0
 def test_update_labels(self):
     name = "yocontainer"
     container = utils.create_container(name=name)
     name = "yopod-{0}".format(str(uuid.uuid4()))
     pod = utils.create_pod(name=name)
     pod.add_container(container)
     if utils.is_reachable(pod.config.api_host):
         pod.create()
         labels = pod.labels
         labels['yomama'] = 'sofat'
         pods = K8sPod.get_by_labels(config=pod.config, labels=labels)
         self.assertIsInstance(pods, list)
         self.assertEqual(0, len(pods))
         pod.labels = labels
         pod.update()
         pods = K8sPod.get_by_labels(config=pod.config, labels=labels)
         self.assertIsInstance(pods, list)
         self.assertEqual(1, len(pods))
예제 #5
0
 def test_update_labels(self):
     name = "yocontainer"
     container = utils.create_container(name=name)
     name = "yopod-{0}".format(str(uuid.uuid4()))
     pod1 = utils.create_pod(name=name)
     pod1.add_container(container)
     if utils.is_reachable(pod1.config.api_host):
         pod1.create()
         labels = pod1.get_labels()
         labels['yomama'] = 'sofat'
         pods = K8sPod.get_by_labels(config=pod1.config, labels=labels)
         self.assertIsInstance(pods, list)
         self.assertEqual(0, len(pods))
         pod1.set_labels(labels)
         pod1.update()
         pods = K8sPod.get_by_labels(config=pod1.config, labels=labels)
         self.assertIsInstance(pods, list)
         self.assertEqual(1, len(pods))
예제 #6
0
 def test_get_by_labels(self):
     name = "yocontainer"
     container = utils.create_container(name=name)
     name = "yopod-{0}".format(str(uuid.uuid4()))
     pod = utils.create_pod(name=name)
     pod.add_container(container)
     if utils.is_reachable(pod.config.api_host):
         pod.create()
         pods = K8sPod.get_by_labels(config=pod.config, labels={'name': name})
         self.assertIsInstance(pods, list)
         self.assertEqual(1, len(pods))
예제 #7
0
 def test_get_by_labels(self):
     name = "yocontainer"
     container = _utils.create_container(name=name)
     name = "yopod-{0}".format(str(uuid.uuid4()))
     pod = _utils.create_pod(name=name)
     pod.add_container(container)
     if _utils.is_reachable(pod.config):
         pod.create()
         pods = K8sPod.get_by_labels(config=pod.config, labels={'name': name})
         self.assertIsInstance(pods, list)
         self.assertEqual(1, len(pods))
         self.assertEqual(pod, pods[0])
예제 #8
0
 def test_get_by_labels_invalid_args(self):
     name = object()
     config = utils.create_config()
     with self.assertRaises(SyntaxError):
         K8sPod.get_by_labels(config=config, labels=name)
예제 #9
0
 def test_get_by_labels_none_args(self):
     config = utils.create_config()
     with self.assertRaises(SyntaxError):
         K8sPod.get_by_labels(config=config)
예제 #10
0
 def test_get_by_labels_none_args(self):
     try:
         K8sPod.get_by_labels()
         self.fail("Should not fail.")
     except Exception as err:
         self.assertIsInstance(err, SyntaxError)