def test_aws_set_volume_id(self): name = "yoname" _type = "awsElasticBlockStore" volume_id = "vol-0a89c9040d544a371" vol = _utils.create_pv(name=name, type=_type) vol.volume_id = volume_id self.assertEqual(vol.volume_id, volume_id)
def test_api_create_gce_pd(self): pvname = "yopv" pvcname = "yopvc" volname = "yovolume" podname = "yopod" contname = "yocontainer" pvtype = "gcePersistentDisk" pv = _utils.create_pv(name=pvname, type=pvtype) pv.pd_name = "mnubo-disk1" pv.fs_type = "xfs" pvc = _utils.create_pvc(name=pvcname) vol = _utils.create_volume(name=volname, type="persistentVolumeClaim") vol.claim_name = pvcname container = _utils.create_container(name=contname, image="nginx:latest") volmount = _utils.create_volume_mount(name=volname, mount_path="/test-persistent") container.add_volume_mount(volmount) pod = _utils.create_pod(name=podname) pod.add_volume(vol) pod.add_container(container) if _utils.is_reachable(pvc.config): try: pv.create() pvc.create() pod.create() self.assertIsInstance(pv, K8sPersistentVolume) self.assertIsInstance(pvc, K8sPersistentVolumeClaim) except Exception as err: self.assertIsInstance(err, TimedOutException)
def test_hostpath_set_path(self): name = "yoname" _type = "hostPath" host_path = "/path/on/host" vol = _utils.create_pv(name=name, type=_type) vol.path = host_path self.assertEqual(host_path, vol.path)
def test_nfs_set_server_invalid_type(self): name = "yoname" _type = "hostPath" server = "nfs.company.com" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(NotImplementedError): vol.nfs_server = server
def test_aws_set_fs_type(self): name = "yoname" _type = "awsElasticBlockStore" fs_type = "xfs" vol = _utils.create_pv(name=name, type=_type) vol.fs_type = fs_type self.assertEqual(vol.fs_type, fs_type)
def test_hostpath_set_path_invalid_type(self): name = "yoname" _type = "gcePersistentDisk" host_path = "/path/on/host" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(NotImplementedError): vol.path = host_path
def test_aws_set_volume_id_invalid_type(self): name = "yoname" _type = "hostPath" volume_id = "vol-0a89c9040d544a371" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(NotImplementedError): vol.volume_id = volume_id
def test_gce_set_fs_type(self): name = "yoname" _type = "gcePersistentDisk" fs_type = "xfs" vol = _utils.create_pv(name=name, type=_type) vol.fs_type = fs_type self.assertEqual(vol.fs_type, fs_type)
def test_nfs_set_server(self): name = "yoname" _type = "nfs" server = "nfs.company.com" vol = _utils.create_pv(name=name, type=_type) vol.nfs_server = server self.assertEqual(vol.nfs_server, server)
def test_gce_fs_type_invalid_obj(self): name = "yoname" _type = "gcePersistentDisk" fs_type = object() vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.fs_type = fs_type
def test_fs_type_invalid_type(self): name = "yoname" _type = "hostPath" fs_type = object() vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(NotImplementedError): vol.fs_type = fs_type
def test_gce_set_pd_name(self): name = "yoname" _type = "gcePersistentDisk" pd_name = "vol-0a89c9040d544a371" vol = _utils.create_pv(name=name, type=_type) vol.pd_name = pd_name self.assertEqual(vol.pd_name, pd_name)
def test_nfs_set_server_invalid(self): name = "yoname" _type = "nfs" server = object() vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.nfs_server = server
def test_gce_set_pd_name_invalid_type(self): name = "yoname" _type = "hostPath" pd_name = "yopdname" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(NotImplementedError): vol.pd_name = pd_name
def test_api_create_nfs(self): pvname = "yopv" pvcname = "yopvc" volname = "yovolume" podname = "yopod" contname = "yocontainer" pvtype = "nfs" pv = _utils.create_pv(name=pvname, type=pvtype) pv.nfs_server = "nfs.company.com" pv.nfs_path = "/fs1/test-nfs" pvc = _utils.create_pvc(name=pvcname) vol = _utils.create_volume(name=volname, type='persistentVolumeClaim') vol.claim_name = pvcname container = _utils.create_container(name=contname, image="nginx:latest") volmount = _utils.create_volume_mount(name=volname, mount_path='/test-persistent') container.add_volume_mount(volmount) pod = _utils.create_pod(name=podname) pod.add_volume(vol) pod.add_container(container) if _utils.is_reachable(pvc.config): try: pv.create() pvc.create() pod.create() self.assertIsInstance(pv, K8sPersistentVolume) self.assertIsInstance(pvc, K8sPersistentVolumeClaim) except Exception as err: self.assertIsInstance(err, TimedOutException)
def test_api_create_aws_ebs(self): pvname = "yopv" pvcname = "yopvc" volname = "yovolume" podname = "yopod" contname = "yocontainer" pvtype = "awsElasticBlockStore" pv = _utils.create_pv(name=pvname, type=pvtype) pv.volume_id = "vol-0e3056a2" pv.fs_type = "xfs" pvc = _utils.create_pvc(name=pvcname) vol = _utils.create_volume(name=volname, type='persistentVolumeClaim') vol.claim_name = pvcname container = _utils.create_container(name=contname, image="nginx:latest") volmount = _utils.create_volume_mount(name=volname, mount_path='/test-persistent') container.add_volume_mount(volmount) pod = _utils.create_pod(name=podname) pod.add_volume(vol) pod.add_container(container) if _utils.is_reachable(pvc.config): try: pv.create() pvc.create() pod.create() self.assertIsInstance(pv, K8sPersistentVolume) self.assertIsInstance(pvc, K8sPersistentVolumeClaim) except Exception as err: self.assertIsInstance(err, TimedOutException)
def test_aws_fs_type_invalid_obj(self): name = "yoname" _type = "awsElasticBlockStore" fs_type = object() vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.fs_type = fs_type
def test_aws_init(self): name = "yoname" _type = "awsElasticBlockStore" vol = _utils.create_pv(name=name, type=_type) self.assertIsNotNone(vol) self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(_type, vol.type) self.assertIsInstance(vol.source, AWSElasticBlockStoreVolumeSource)
def test_gce_init(self): name = "yoname" _type = "gcePersistentDisk" vol = _utils.create_pv(name=name, type=_type) self.assertIsNotNone(vol) self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(_type, vol.type) self.assertIsInstance(vol.source, GCEPersistentDiskVolumeSource)
def test_init_host_path(self): name = "yoname" _type = 'hostPath' vol = _utils.create_pv(name=name, type=_type) self.assertIsNotNone(vol) self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual('hostPath', vol.type) self.assertIsInstance(vol.source, HostPathVolumeSource)
def test_nfs_init(self): name = "yoname" _type = "nfs" vol = _utils.create_pv(name=name, type=_type) self.assertIsNotNone(vol) self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(_type, vol.type) self.assertIsInstance(vol.source, NFSVolumeSource)
def test_api_hostpath(self): name = "yoname" _type = "hostPath" host_path = "/path/on/host" vol = _utils.create_pv(name=name, type=_type) vol.path = host_path self.assertEqual(host_path, vol.path) if _utils.is_reachable(vol.config): vol.create() self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(host_path, vol.path)
def test_list(self): name = "yoname" _type = "gcePersistentDisk" pd_name = "mnubo-disk1" fs_type = 'xfs' vol = _utils.create_pv(name=name, type=_type) vol.pd_name = pd_name vol.fs_type = fs_type if _utils.is_reachable(vol.config): vol.create() _list = vol.list() for x in _list: self.assertIsInstance(x, K8sPersistentVolume)
def test_api_gce_pd(self): name = "yoname" _type = "gcePersistentDisk" pd_name = "mnubo-disk1" fs_type = 'xfs' vol = _utils.create_pv(name=name, type=_type) vol.pd_name = pd_name vol.fs_type = fs_type if _utils.is_reachable(vol.config): vol.create() self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(vol.pd_name, pd_name) self.assertEqual(vol.fs_type, fs_type)
def test_api_nfs(self): name = "yoname" _type = "nfs" server = "nfs.company.com" path = "/some/path" vol = _utils.create_pv(name=name, type=_type) vol.nfs_server = server vol.nfs_path = path if _utils.is_reachable(vol.config): vol.create() self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(vol.nfs_server, server) self.assertEqual(vol.nfs_path, path)
def test_api_aws_ebs(self): name = "yoname" _type = "awsElasticBlockStore" volume_id = "vol-0e3056a2" fs_type = 'xfs' vol = _utils.create_pv(name=name, type=_type) vol.volume_id = volume_id vol.fs_type = fs_type if _utils.is_reachable(vol.config): vol.create() self.assertIsInstance(vol, K8sPersistentVolume) self.assertEqual(vol.volume_id, volume_id) self.assertEqual(vol.fs_type, fs_type)
def test_aws_set_fs_type_none(self): name = "yoname" _type = "awsElasticBlockStore" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.fs_type = None
def test_gce_set_fs_type_none(self): name = "yoname" _type = "gcePersistentDisk" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.fs_type = None
def test_hostpath_set_path_none(self): name = "yoname" _type = "hostPath" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.path = None
def test_nfs_set_server_none(self): name = "yoname" _type = "nfs" vol = _utils.create_pv(name=name, type=_type) with self.assertRaises(SyntaxError): vol.nfs_server = None