Fix meta-service for server integration tests
* Updated CreateShardGroup to not return an error if it already exists so it's idempotent * Removed old test making sure you can't delete the default RP. You can delete it now, there was no reason to disallow it. * Wired up the UpdateRetentionPolicy functionalitypull/5428/head
parent
2715d5ef72
commit
101ab32571
|
@ -340,11 +340,6 @@ func init() {
|
|||
command: `SHOW RETENTION POLICIES ON db0`,
|
||||
exp: `{"results":[{"series":[{"columns":["name","duration","replicaN","default"],"values":[["rp0","2h0m0s",3,true]]}]}]}`,
|
||||
},
|
||||
&Query{
|
||||
name: "dropping default retention policy should not succeed",
|
||||
command: `DROP RETENTION POLICY rp0 ON db0`,
|
||||
exp: `{"results":[{"error":"retention policy is default"}]}`,
|
||||
},
|
||||
&Query{
|
||||
name: "show retention policy should still show policy",
|
||||
command: `SHOW RETENTION POLICIES ON db0`,
|
||||
|
|
|
@ -4285,7 +4285,7 @@ func TestServer_Query_Where_With_Tags(t *testing.T) {
|
|||
name: "where on tag that should be double quoted but isn't",
|
||||
params: url.Values{"db": []string{"db0"}},
|
||||
command: `show series where data-center = 'foo'`,
|
||||
exp: `{"results":[{"error":"invalid expression: data - center = 'foo'"}]}`,
|
||||
exp: `{"error":"error parsing query: found DATA, expected identifier, string, number, bool at line 1, char 19"}`,
|
||||
},
|
||||
}...)
|
||||
|
||||
|
|
|
@ -101,6 +101,12 @@ func (c *Client) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Data() *Data {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
return c.data
|
||||
}
|
||||
|
||||
// ClusterID returns the ID of the cluster it's connected to.
|
||||
func (c *Client) ClusterID() uint64 {
|
||||
c.mu.RLock()
|
||||
|
@ -314,7 +320,32 @@ func (c *Client) SetDefaultRetentionPolicy(database, name string) error {
|
|||
|
||||
// UpdateRetentionPolicy updates a retention policy.
|
||||
func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error {
|
||||
return nil
|
||||
var newName *string
|
||||
if rpu.Name != nil {
|
||||
newName = rpu.Name
|
||||
}
|
||||
|
||||
var duration *int64
|
||||
if rpu.Duration != nil {
|
||||
value := int64(*rpu.Duration)
|
||||
duration = &value
|
||||
}
|
||||
|
||||
var replicaN *uint32
|
||||
if rpu.ReplicaN != nil {
|
||||
value := uint32(*rpu.ReplicaN)
|
||||
replicaN = &value
|
||||
}
|
||||
|
||||
cmd := &internal.UpdateRetentionPolicyCommand{
|
||||
Database: proto.String(database),
|
||||
Name: proto.String(name),
|
||||
NewName: newName,
|
||||
Duration: duration,
|
||||
ReplicaN: replicaN,
|
||||
}
|
||||
|
||||
return c.retryUntilExec(internal.Command_UpdateRetentionPolicyCommand, internal.E_UpdateRetentionPolicyCommand_Command, cmd)
|
||||
}
|
||||
|
||||
// IsLeader - should get rid of this
|
||||
|
@ -557,6 +588,10 @@ func (c *Client) ShardGroupsByTimeRange(database, policy string, min, max time.T
|
|||
|
||||
// CreateShardGroup creates a shard group on a database and policy for a given timestamp.
|
||||
func (c *Client) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error) {
|
||||
if sg, _ := c.Data().ShardGroupByTimestamp(database, policy, timestamp); sg != nil {
|
||||
return sg, nil
|
||||
}
|
||||
|
||||
cmd := &internal.CreateShardGroupCommand{
|
||||
Database: proto.String(database),
|
||||
Policy: proto.String(policy),
|
||||
|
@ -864,7 +899,7 @@ func (c *Client) exec(url string, typ internal.Command_Type, desc *proto.Extensi
|
|||
if resp.StatusCode == http.StatusTemporaryRedirect {
|
||||
return 0, errRedirect{host: resp.Header.Get("Location")}
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
return 0, fmt.Errorf("unexpected result:\n\texp: %d\n\tgot: %d\n", http.StatusOK, resp.StatusCode)
|
||||
return 0, fmt.Errorf("meta service returned %s", resp.Status)
|
||||
}
|
||||
|
||||
res := &internal.Response{}
|
||||
|
@ -879,7 +914,7 @@ func (c *Client) exec(url string, typ internal.Command_Type, desc *proto.Extensi
|
|||
}
|
||||
es := res.GetError()
|
||||
if es != "" {
|
||||
return 0, fmt.Errorf("exec err: %s", es)
|
||||
return 0, fmt.Errorf(es)
|
||||
}
|
||||
|
||||
return res.GetIndex(), nil
|
||||
|
|
|
@ -438,7 +438,7 @@ func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time)
|
|||
|
||||
// Verify that shard group doesn't already exist for this timestamp.
|
||||
if rpi.ShardGroupByTimestamp(timestamp) != nil {
|
||||
return ErrShardGroupExists
|
||||
return nil
|
||||
}
|
||||
|
||||
// Require at least one replica but no more replicas than nodes.
|
||||
|
|
Loading…
Reference in New Issue