Test create input definition across 2 servers

This commit is contained in:
Michael Baird 2017-06-19 13:18:20 -05:00
parent 3cecd74e2e
commit 23e7e42d99

View file

@ -494,6 +494,29 @@ func TestMain_SendReceiveMessage(t *testing.T) {
if maxSlices1["i"] != 2 {
t.Fatalf("unexpected maxSlice on node1: %d", maxSlices1["i"])
}
// Write input definition to the first node.
if _, err := m0.CreateDefinition("i", "test", `{
"frames": [{"name": "event-time",
"options": {
"cacheType": "ranked",
"timeQuantum": "YMD"
}}],
"fields": [{"name": "id",
"primaryKey": true
}]}
`); err != nil {
t.Fatal(err)
}
frame0 := m0.Server.Holder.Frame("i", "event-time")
if frame0 == nil {
t.Fatal("frame not found")
}
frame1 := m1.Server.Holder.Frame("i", "event-time")
if frame1 == nil {
t.Fatal("frame not found")
}
}
// availablePorts returns a slice of ports that can be used for testing.
@ -615,6 +638,15 @@ func (m *Main) Query(index, rawQuery, query string) (string, error) {
return resp.Body, nil
}
// CreateDefinition.
func (m *Main) CreateDefinition(index, def, query string) (string, error) {
resp := MustDo("POST", m.URL()+fmt.Sprintf("/index/%s/input-definition/%s", index, def), query)
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("invalid status: %d, body=%s", resp.StatusCode, resp.Body)
}
return resp.Body, nil
}
// SetCommand represents a command to set a bit.
type SetCommand struct {
ID uint64