This file is indexed.

/usr/share/gocode/src/github.com/influxdata/influxdb/services/precreator/service_test.go is in golang-github-influxdb-influxdb-dev 1.1.1+dfsg1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package precreator

import (
	"sync"
	"testing"
	"time"

	"github.com/influxdata/influxdb/toml"
)

func Test_ShardPrecreation(t *testing.T) {
	t.Parallel()

	now := time.Now().UTC()
	advancePeriod := 5 * time.Minute

	// A test metastaore which returns 2 shard groups, only 1 of which requires a successor.
	var wg sync.WaitGroup
	wg.Add(1)
	ms := metaClient{
		PrecreateShardGroupsFn: func(v, u time.Time) error {
			wg.Done()
			if u != now.Add(advancePeriod) {
				t.Fatalf("precreation called with wrong time, got %s, exp %s", u, now)
			}
			return nil
		},
	}

	srv, err := NewService(Config{
		CheckInterval: toml.Duration(time.Minute),
		AdvancePeriod: toml.Duration(advancePeriod),
	})
	if err != nil {
		t.Fatalf("failed to create shard precreation service: %s", err.Error())
	}
	srv.MetaClient = ms

	err = srv.precreate(now)
	if err != nil {
		t.Fatalf("failed to precreate shards: %s", err.Error())
	}

	wg.Wait() // Ensure metaClient test function is called.
	return
}

// PointsWriter represents a mock impl of PointsWriter.
type metaClient struct {
	PrecreateShardGroupsFn func(now, cutoff time.Time) error
}

func (m metaClient) PrecreateShardGroups(now, cutoff time.Time) error {
	return m.PrecreateShardGroupsFn(now, cutoff)
}