-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add initial HDFS tests Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Install Java and libhdfs.so for tests * Fix kokorun Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
HADOOP_VERSION=2.7.0 | ||
docker pull sequenceiq/hadoop-docker:$HADOOP_VERSION | ||
docker run -d --rm --net=host --name=tensorflow-io-hdfs sequenceiq/hadoop-docker:$HADOOP_VERSION | ||
echo "Waiting for 30 secs until hadoop is up and running" | ||
sleep 30 | ||
docker logs tensorflow-io-hdfs | ||
echo "Hadoop up" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# ============================================================================== | ||
"""Tests for HDFS file system""" | ||
|
||
import os | ||
import sys | ||
import socket | ||
import time | ||
import tempfile | ||
import tensorflow as tf | ||
import tensorflow_io as tfio | ||
import pytest | ||
|
||
|
||
@pytest.mark.skipif( | ||
sys.platform in ("win32", "darwin"), | ||
reason="TODO HDFS not setup properly on macOS/Windows yet", | ||
) | ||
def test_read_file(): | ||
"""Test case for reading HDFS""" | ||
|
||
address = socket.gethostbyname(socket.gethostname()) | ||
print("ADDRESS: {}".format(address)) | ||
|
||
body = b"1234567" | ||
tf.io.write_file("hdfse://{}:9000/file.txt".format(address), body) | ||
|
||
content = tf.io.read_file("hdfse://{}:9000/file.txt".format(address)) | ||
print("CONTENT: {}".format(content)) | ||
assert content == body |