File: datanode_failover_test.go

package info (click to toggle)
golang-github-colinmarc-hdfs 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,760 kB
  • sloc: sh: 130; xml: 40; makefile: 31
file content (28 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package transfer

import (
	"testing"
	"time"

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

func TestPicksFirstDatanode(t *testing.T) {
	df := newDatanodeFailover([]string{"foo:6000", "bar:6000"})
	assert.EqualValues(t, df.next(), "foo:6000")
}

func TestPicksDatanodesWithoutFailures(t *testing.T) {
	df := newDatanodeFailover([]string{"foo:6000", "foo:7000", "bar:6000"})
	datanodeFailures["foo:6000"] = time.Now()

	assert.EqualValues(t, df.next(), "foo:7000")
}

func TestPicksDatanodesWithOldestFailures(t *testing.T) {
	df := newDatanodeFailover([]string{"foo:6000", "bar:6000"})
	datanodeFailures["foo:6000"] = time.Now().Add(-10 * time.Minute)
	datanodeFailures["bar:6000"] = time.Now()

	assert.EqualValues(t, df.next(), "foo:6000")
}