Skip to content

Commit

Permalink
Hack for truncate test: wait 2 seconds for truncate operation
Browse files Browse the repository at this point in the history
  • Loading branch information
junjieqian committed Mar 29, 2017
1 parent 48afdbc commit 7779883
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion file_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ func TestFileAppendRepeatedly(t *testing.T) {
}

func TestFileTruncate(t *testing.T) {
t.Skip("Truncate not support in Hadoop-2.6")
if os.Getenv("HADOOP_DISTRO") == "cdh" {
t.Skip("Truncate not support in Hadoop-2.6")
}
client := getClient(t)

baleet(t, "/_test/create/5.txt")
Expand All @@ -363,6 +365,8 @@ func TestFileTruncate(t *testing.T) {
writer.Close()
err = writer.Truncate(3)
require.NoError(t, err)
time.Sleep(3 * time.Second)

stat, err := client.Stat("/_test/create/5.txt")
require.NoError(t, err)
time.Sleep(time.Second)
Expand Down
8 changes: 6 additions & 2 deletions truncate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ package hdfs
import (
"os"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestTruncate(t *testing.T) {
t.Skip("Truncate not support in Hadoop-2.6")
if os.Getenv("HADOOP_DISTRO") == "cdh" {
t.Skip("Truncate not support in Hadoop-2.6")
}
client := getClient(t)

baleet(t, "/_test/truncate/1.txt")
mkdirp(t, "/_test/truncate")
writer, _ := client.Create("/_test/truncate/1.txt")
_, _ = writer.Write([]byte("foobar\nfoobar\n"))
_ = writer.Close()
_ = writer.Close()

err := client.Truncate("/_test/truncate/1.txt", 4)
require.NoError(t, err)
time.Sleep(3 * time.Second)

stat, err := client.Stat("/_test/truncate/1.txt")
require.NoError(t, err)
Expand Down

0 comments on commit 7779883

Please sign in to comment.