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)))
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')))
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]))
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))
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')))
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'))
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'))