Exemplo n.º 1
0
 def test_path_exists_svc(self):
     client = KubernetesClient()
     svc = client.get_services()
     svc1 = svc[0]
     kp = KubePath()
     kp.parse_path('/default/svc/%s/describe' % svc1)
     assert_that(kp.exists(client), is_(True))
Exemplo n.º 2
0
 def test_path_exists_pod(self):
     client = KubernetesClient()
     pods = client.get_pods()
     pod1 = pods[0]
     kp = KubePath()
     kp.parse_path('/default/pod/%s/describe' % pod1)
     assert_that(kp.exists(client), is_(True))
Exemplo n.º 3
0
 def test_list_files_for_resource(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     path = '/default/pod'
     files = fs.list_files(path)
     pods = client.get_pods()
     assert_that(files, contains(*pods))
Exemplo n.º 4
0
 def test_path_exists_invalid_action(self):
     client = KubernetesClient()
     pods = client.get_pods()
     pod1 = pods[0]
     kp = KubePath()
     kp.parse_path('/default/pod/%s/invalid-action' % pod1)
     assert_that(kp.exists(client), is_(False))
Exemplo n.º 5
0
 def test_read_logs(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/logs' % pod
     data = fs.read(path, 50000, 0)
     assert_that(data, equal_to(client.logs('default', pod)))
Exemplo n.º 6
0
 def test_read_logs(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/logs' % pod
     data = fs.read(path, 50000, 0)
     assert_that(data, equal_to(client.logs('default', pod)))
Exemplo n.º 7
0
 def test_read_yaml(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/yaml' % pod
     data = fs.read(path, 50000, 0)
     assert_that(data, equal_to(client.get_object_in_format('default', 'pod', pod, 'yaml')))
Exemplo n.º 8
0
 def test_list_files_for_resource(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     path = '/default/pod'
     files = fs.list_files(path)
     pods = client.get_pods()
     assert_that(files, contains(*pods))
Exemplo n.º 9
0
 def test_path_exists_rc(self):
     client = KubernetesClient()
     rc = client.get_replication_controllers()
     rc1 = rc[0]
     kp = KubePath()
     kp.parse_path('/default/rc/%s/describe' % rc1)
     assert_that(kp.exists(client), is_(True))
Exemplo n.º 10
0
 def test_getattr_for_truncated_file(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/json' % pod
     fs.truncate(path, 0)
     attr = fs.getattr(path)
     assert_that(attr['st_size'], is_(0))
Exemplo n.º 11
0
 def test_getattr_size_for_describe_action(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/logs' % pod
     attr = fs.getattr(path)
     data = client.logs('default', pod)
     assert_that(attr['st_size'], is_(len(data)))
Exemplo n.º 12
0
 def test_getattr_size_for_yaml_action(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/yaml' % pod
     attr = fs.getattr(path)
     data = client.get_object_in_format('default', 'pod', pod, 'yaml')
     assert_that(attr['st_size'], is_(len(data)))
Exemplo n.º 13
0
 def test_read_length(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/yaml' % pod
     data = fs.read(path, 10, 0)
     ref = client.get_object_in_format('default', 'pod', pod, 'yaml')
     assert_that(data, equal_to(ref[:10]))
Exemplo n.º 14
0
 def test_list_files_for_rc(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     rc = client.get_replication_controllers()[0]
     path = '/default/rc/%s' % rc
     files = fs.list_files(path)
     assert_that(files, has_items('describe', 'json', 'yaml'))
     assert_that(len(files), is_(3))
Exemplo n.º 15
0
 def test_list_files_for_pod(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s' % pod
     files = fs.list_files(path)
     assert_that(files, has_items('describe', 'logs', 'json', 'yaml'))
     assert_that(len(files), is_(4))
Exemplo n.º 16
0
 def test_list_files_for_root(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     path = '/'
     files = fs.list_files(path)
     namespaces = client.get_namespaces()
     assert_that(files, contains(*namespaces))
     assert_that(len(files), is_(len(namespaces)))
Exemplo n.º 17
0
 def test_list_files_for_root(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     path = '/'
     files = fs.list_files(path)
     namespaces = client.get_namespaces()
     assert_that(files, contains(*namespaces))
     assert_that(len(files), is_(len(namespaces)))
Exemplo n.º 18
0
 def test_getattr_for_truncated_file(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/json' % pod
     fs.truncate(path, 0)
     attr = fs.getattr(path)
     assert_that(attr['st_size'], is_(0))
Exemplo n.º 19
0
 def test_list_files_for_rc(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     rc = client.get_replication_controllers()[0]
     path = '/default/rc/%s' % rc
     files = fs.list_files(path)
     assert_that(files, has_items('describe', 'json', 'yaml'))
     assert_that(len(files), is_(3))
Exemplo n.º 20
0
 def test_list_files_for_pod(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s' % pod
     files = fs.list_files(path)
     assert_that(files, has_items('describe', 'logs', 'json', 'yaml'))
     assert_that(len(files), is_(4))
Exemplo n.º 21
0
 def test_getattr_size_for_yaml_action(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/yaml' % pod
     attr = fs.getattr(path)
     data = client.get_object_in_format('default', 'pod', pod, 'yaml')
     assert_that(attr['st_size'], is_(len(data)))
Exemplo n.º 22
0
 def test_getattr_size_for_describe_action(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/logs' % pod
     attr = fs.getattr(path)
     data = client.logs('default', pod)
     assert_that(attr['st_size'], is_(len(data)))
Exemplo n.º 23
0
 def test_read_offset(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/yaml' % pod
     data = fs.read(path, 10, 5)
     ref = client.get_object_in_format('default', 'pod', pod, 'yaml')
     assert_that(data, equal_to(ref[5:15]))
     assert_that(len(data), is_(10))
Exemplo n.º 24
0
 def test_getattr_for_object(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s' % pod
     attr = fs.getattr(path)
     assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0555))
     assert_that(attr['st_nlink'], is_(2))
     assert_that(attr['st_size'], is_(0))
Exemplo n.º 25
0
 def test_getattr_for_object(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s' % pod
     attr = fs.getattr(path)
     assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0o555))
     assert_that(attr['st_nlink'], is_(2))
     assert_that(attr['st_size'], is_(0))
Exemplo n.º 26
0
 def test_read_offset(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/yaml' % pod
     data = fs.read(path, 10, 5)
     ref = client.get_object_in_format('default', 'pod', pod, 'yaml')
     assert_that(data, equal_to(ref[5:15]))
     assert_that(len(data), is_(10))
Exemplo n.º 27
0
 def test_read_json(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/json' % pod
     data = fs.read(path, 50000, 0)
     assert_that(
         data,
         equal_to(client.get_object_in_format('default', 'pod', pod,
                                              'json')))
Exemplo n.º 28
0
 def test_getattr_for_action(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/describe' % pod
     attr = fs.getattr(path)
     data = client.describe('default', 'pod', pod)
     assert_that(attr['st_mode'], is_(stat.S_IFREG | 0444))
     assert_that(attr['st_nlink'], is_(1))
     assert_that(attr['st_size'], is_(len(data)))
Exemplo n.º 29
0
 def test_getattr_for_action(self):
     client = KubernetesClient()
     pod = client.get_pods()[0]
     fs = KubeFileSystem(client)
     path = '/default/pod/%s/describe' % pod
     attr = fs.getattr(path)
     data = client.describe('default', 'pod', pod)
     assert_that(attr['st_mode'], is_(stat.S_IFREG | 0o444))
     assert_that(attr['st_nlink'], is_(1))
     assert_that(attr['st_size'], is_(len(data)))
Exemplo n.º 30
0
 def test_truncate_and_write(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/yaml' % pod
     fs.truncate(path, 0)
     fs.write(path, 'test', 0)
     fs.write(path, 'write', 4)
     fs.sync(path, dry_run=True)
     data = fs.read(path, 1000, 0)
     assert_that(data, is_('testwrite'))
Exemplo n.º 31
0
 def test_truncate_and_write(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/yaml' % pod
     fs.truncate(path, 0)
     fs.write(path, 'test', 0)
     fs.write(path, 'write', 4)
     fs.sync(path, dry_run=True)
     data = fs.read(path, 1000, 0)
     assert_that(data, is_(b'testwrite'))
Exemplo n.º 32
0
 def test_getattr_for_resource(self):
     fs = KubeFileSystem(KubernetesClient())
     path = '/default/pod'
     attr = fs.getattr(path)
     assert_that(attr['st_mode'], is_(stat.S_IFDIR | 0555))
     assert_that(attr['st_nlink'], is_(2))
     assert_that(attr['st_size'], is_(0))
Exemplo n.º 33
0
 def test_list_files_for_namespace(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     path = '/default'
     files = fs.list_files(path)
     assert_that(
         files,
         contains('pod', 'svc', 'rc', 'nodes', 'events', 'cs', 'limits',
                  'pv', 'pvc', 'quota', 'endpoints', 'serviceaccounts',
                  'secrets'))
Exemplo n.º 34
0
 def test_list_files_for_namespace(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     path = '/default'
     files = fs.list_files(path)
     assert_that(
         files,
         contains_inanyorder('pod', 'svc', 'rc', 'deployments', 'nodes',
                             'events', 'limits', 'pv', 'pvc', 'quota',
                             'endpoints', 'serviceaccounts', 'jobs',
                             'replicasets', 'configmaps', 'secrets',
                             'componentstatuses', 'daemonsets',
                             'horizontalpodautoscalers', 'ingress'))
Exemplo n.º 35
0
 def test_get_object_in_yaml_format(self):
     client = KubernetesClient()
     pods = client.get_pods("default")
     pod = client.get_object_in_format('default', 'pod', pods[0], 'yaml')
     result = yaml.load(pod)
     assert_that(result['metadata']['name'], is_(pods[0]))
Exemplo n.º 36
0
 def test_get_object_in_json_format(self):
     client = KubernetesClient()
     pods = client.get_pods("default")
     pod = client.get_object_in_format('default', 'pod', pods[0], 'json')
     result = json.loads(pod)
     assert_that(result['metadata']['name'], is_(pods[0]))
Exemplo n.º 37
0
 def test_get_replication_controllers(self):
     client = KubernetesClient()
     rc = client.get_replication_controllers('default')
     assert_that(len(rc), is_(3))
Exemplo n.º 38
0
 def test_get_namespaces(self):
     client = KubernetesClient()
     namespaces = client.get_namespaces()
     assert_that(namespaces, has_item('default'))
     assert_that(namespaces, has_item('kube-system'))
     assert_that(len(namespaces), is_(2))
Exemplo n.º 39
0
 def test_logs(self):
     client = KubernetesClient()
     pods = client.get_pods("default")
     describe = client.logs('default', pods[0])
     assert_that(describe, contains_string(pods[0]))
Exemplo n.º 40
0
 def test_describe(self):
     client = KubernetesClient()
     pods = client.get_pods("default")
     describe = client.describe('default', 'pod', pods[0])
     assert_that(describe, contains_string(pods[0]))
Exemplo n.º 41
0
 def test_path_exists_invalid_object_id(self):
     client = KubernetesClient()
     kp = KubePath()
     kp.parse_path('/default/pod/invalid-id')
     assert_that(kp.exists(client), is_(False))
Exemplo n.º 42
0
 def test_list_files_for_file_throws_exception(self):
     client = KubernetesClient()
     fs = KubeFileSystem(client)
     pod = client.get_pods()[0]
     path = '/default/pod/%s/describe' % pod
     assert_that(calling(lambda: fs.list_files(path)), raises(FuseOSError))
Exemplo n.º 43
0
 def test_get_pods(self):
     client = KubernetesClient()
     pods = client.get_pods('default')
     assert_that(len(pods), is_(3))
Exemplo n.º 44
0
 def test_get_services(self):
     client = KubernetesClient()
     svc = client.get_services('default')
     assert_that(len(svc), is_(4))
Exemplo n.º 45
0
 def test_get_replication_controllers(self):
     client = KubernetesClient()
     rc = client.get_replication_controllers('default')
     assert_that(len(rc), is_(3))
Exemplo n.º 46
0
 def test_get_services(self):
     client = KubernetesClient()
     svc = client.get_services('default')
     assert_that(len(svc), is_(4))
Exemplo n.º 47
0
 def test_get_namespaces(self):
     client = KubernetesClient()
     namespaces = client.get_namespaces()
     assert_that(namespaces, has_item('default'))
     assert_that(namespaces, has_item('kube-system'))
     assert_that(len(namespaces), is_(2))
Exemplo n.º 48
0
 def test_logs(self):
     client = KubernetesClient()
     pods = client.get_pods("default")
     describe = client.logs('default', pods[0])
     assert_that(str(describe), contains_string(pods[0]))
Exemplo n.º 49
0
 def test_get_object_in_json_format(self):
     client = KubernetesClient()
     pods = client.get_pods("default")
     pod = client.get_object_in_format('default', 'pod', pods[0], 'json')
     result = json.loads(pod.decode('utf-8'))
     assert_that(result['metadata']['name'], is_(pods[0]))
Exemplo n.º 50
0
 def test_get_pods(self):
     client = KubernetesClient()
     pods = client.get_pods('default')
     assert_that(len(pods), is_(3))