Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit ef078ac

Browse files
committed
add IDK test for expected featurebase commit
We have had some weird problems that look like IDK was being tested against the wrong version of featurebase. Add a test which requests the version, and if an environment variable is set, requires that the featurebase server agrees with it.
1 parent d114680 commit ef078ac

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

idk/ingest_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package idk
33
// comment
44
import (
55
"context"
6+
"encoding/json"
67
"fmt"
78
"io"
89
"math/rand"
@@ -62,6 +63,48 @@ func configureTestFlagsController(main *Main, address dax.Address, qtbl *dax.Qua
6263
}
6364
}
6465

66+
type versionHolder struct {
67+
Version string
68+
}
69+
70+
func TestFeaturebaseVersion(t *testing.T) {
71+
m := NewMain()
72+
configureTestFlags(m)
73+
// We don't need to fully run an ingester, but we do need its client set up.
74+
_, err := m.setupClient()
75+
if err != nil {
76+
t.Fatalf("setting up client: %v", err)
77+
}
78+
c := m.PilosaClient()
79+
status, body, err := c.HTTPRequest("GET", "/version", nil, nil)
80+
if err != nil {
81+
t.Fatalf("getting version: %v", err)
82+
}
83+
if status != http.StatusOK {
84+
t.Fatalf("unexpected status: %d (wanted StatusOK)", status)
85+
}
86+
var vh versionHolder
87+
err = json.Unmarshal(body, &vh)
88+
if err != nil {
89+
t.Fatalf("unmarshalling version: %v", err)
90+
}
91+
v := vh.Version
92+
expectedHash := os.Getenv("IDK_FEATUREBASE_HASH")
93+
if expectedHash == "" {
94+
t.Skipf("featurebase version: %s [no expected version]", v)
95+
}
96+
offset := strings.LastIndex(v, "-g")
97+
if offset == -1 {
98+
t.Fatalf("version %s doesn't have -g followed by a hash", v)
99+
}
100+
hash := v[offset+2:]
101+
// allow either hash to be abbreviated
102+
if !strings.HasPrefix(expectedHash, hash) && !strings.HasPrefix(hash, expectedHash) {
103+
t.Fatalf("expected hash to look like %q, got %q", expectedHash, hash)
104+
}
105+
t.Logf("featurebase commit %q matches expectations", hash)
106+
}
107+
65108
func TestErrFlush(t *testing.T) {
66109
ts := newTestSource([]Field{IDField{NameVal: "aval"}},
67110
[][]interface{}{

0 commit comments

Comments
 (0)