remove SetDefaultRetentionPolicy method from meta.Client
parent
cd272ce6c3
commit
6e290040bb
|
@ -34,10 +34,7 @@ func TestServer_BackupAndRestore(t *testing.T) {
|
|||
s := OpenServer(config)
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(db, newRetentionPolicySpec(rp, 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(db, rp); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(db, newRetentionPolicySpec(rp, 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -78,10 +78,7 @@ func OpenServerWithVersion(c *run.Config, version string) *Server {
|
|||
// OpenDefaultServer opens a test server with a default database & retention policy.
|
||||
func OpenDefaultServer(c *run.Config) *Server {
|
||||
s := OpenServer(c)
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return s
|
||||
|
@ -111,10 +108,10 @@ func (s *Server) URL() string {
|
|||
}
|
||||
|
||||
// CreateDatabaseAndRetentionPolicy will create the database and retention policy.
|
||||
func (s *Server) CreateDatabaseAndRetentionPolicy(db string, rp *meta.RetentionPolicySpec) error {
|
||||
func (s *Server) CreateDatabaseAndRetentionPolicy(db string, rp *meta.RetentionPolicySpec, makeDefault bool) error {
|
||||
if _, err := s.MetaClient.CreateDatabase(db); err != nil {
|
||||
return err
|
||||
} else if _, err := s.MetaClient.CreateRetentionPolicy(db, rp, true); err != nil {
|
||||
} else if _, err := s.MetaClient.CreateRetentionPolicy(db, rp, makeDefault); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -455,13 +452,9 @@ func writeTestData(s *Server, t *Test) error {
|
|||
w.rp = t.retentionPolicy()
|
||||
}
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(w.db, newRetentionPolicySpec(w.rp, 1, 0)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(w.db, newRetentionPolicySpec(w.rp, 1, 0), true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(w.db, w.rp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if res, err := s.Write(w.db, w.rp, w.data, t.params); err != nil {
|
||||
return fmt.Errorf("write #%d: %s", i, err)
|
||||
} else if t.exp != res {
|
||||
|
|
|
@ -83,10 +83,7 @@ func TestServer_Query_DropAndRecreateDatabase(t *testing.T) {
|
|||
|
||||
test := tests.load(t, "drop_and_recreate_database")
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(test.database(), test.retentionPolicy()); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -115,13 +112,10 @@ func TestServer_Query_DropDatabaseIsolated(t *testing.T) {
|
|||
|
||||
test := tests.load(t, "drop_database_isolated")
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(test.database(), test.retentionPolicy()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db1", newRetentionPolicySpec("rp1", 1, 0)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db1", newRetentionPolicySpec("rp1", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -150,10 +144,7 @@ func TestServer_Query_DeleteSeries(t *testing.T) {
|
|||
|
||||
test := tests.load(t, "delete_series")
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(test.database(), test.retentionPolicy()); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -182,10 +173,7 @@ func TestServer_Query_DropAndRecreateSeries(t *testing.T) {
|
|||
|
||||
test := tests.load(t, "drop_and_recreate_series")
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(test.database(), test.retentionPolicy()); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -234,10 +222,7 @@ func TestServer_Query_DropSeriesFromRegex(t *testing.T) {
|
|||
|
||||
test := tests.load(t, "drop_series_from_regex")
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy(test.database(), test.retentionPolicy()); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy(test.database(), newRetentionPolicySpec(test.retentionPolicy(), 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -408,7 +393,7 @@ func TestServer_Write_LineProtocol_Float(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -433,7 +418,7 @@ func TestServer_Write_LineProtocol_Bool(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -458,7 +443,7 @@ func TestServer_Write_LineProtocol_String(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -483,7 +468,7 @@ func TestServer_Write_LineProtocol_Integer(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -509,7 +494,7 @@ func TestServer_Write_LineProtocol_Partial(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 1*time.Hour), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -2762,7 +2747,7 @@ func TestServer_Query_MergeMany(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
// set infinite retention policy as we are inserting data in the past and don't want retention policy enforcement to make this test racy
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -2822,7 +2807,7 @@ func TestServer_Query_SLimitAndSOffset(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
// set infinite retention policy as we are inserting data in the past and don't want retention policy enforcement to make this test racy
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -2878,10 +2863,7 @@ func TestServer_Query_Regex(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -3857,10 +3839,7 @@ func TestServer_Query_AggregateSelectors(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4189,10 +4168,7 @@ func TestServer_Query_TopInt(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4356,10 +4332,7 @@ func TestServer_Query_Aggregates_IdenticalTime(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4424,10 +4397,7 @@ func TestServer_Query_GroupByTimeCutoffs(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4506,10 +4476,7 @@ func TestServer_Write_Precision(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4623,10 +4590,7 @@ func TestServer_Query_Wildcards(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4741,10 +4705,7 @@ func TestServer_Query_WildcardExpansion(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4821,10 +4782,7 @@ func TestServer_Query_AcrossShardsAndFields(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -4895,10 +4853,7 @@ func TestServer_Query_Where_Fields(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5117,10 +5072,7 @@ func TestServer_Query_Where_With_Tags(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5205,10 +5157,7 @@ func TestServer_Query_With_EmptyTags(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5302,10 +5251,7 @@ func TestServer_Query_LimitAndOffset(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5419,10 +5365,7 @@ func TestServer_Query_Fill(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5518,10 +5461,7 @@ func TestServer_Query_Chunk(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5570,16 +5510,10 @@ func TestServer_Query_DropAndRecreateMeasurement(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db1", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db1", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db1", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5736,10 +5670,7 @@ func TestServer_Query_ShowQueries_Future(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5808,10 +5739,7 @@ func TestServer_Query_ShowSeries(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5910,10 +5838,7 @@ func TestServer_Query_ShowStats(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -5954,10 +5879,7 @@ func TestServer_Query_ShowMeasurements(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6044,10 +5966,7 @@ func TestServer_Query_ShowTagKeys(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6194,10 +6113,7 @@ func TestServer_Query_ShowFieldKeys(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6260,10 +6176,7 @@ func TestServer_ContinuousQuery(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6386,10 +6299,7 @@ func TestServer_ContinuousQuery_Deadlock(t *testing.T) {
|
|||
s.Server = nil
|
||||
}()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6459,10 +6369,7 @@ func TestServer_Query_EvilIdentifiers(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6503,10 +6410,7 @@ func TestServer_Query_OrderByTime(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6565,10 +6469,7 @@ func TestServer_Query_FieldWithMultiplePeriods(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6619,10 +6520,7 @@ func TestServer_Query_FieldWithMultiplePeriodsMeasurementPrefixMatch(t *testing.
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6673,10 +6571,7 @@ func TestServer_Query_IntoTarget(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6732,10 +6627,7 @@ func TestServer_Query_IntoTarget_Sparse(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6793,10 +6685,7 @@ func TestServer_Query_DuplicateMeasurements(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
// Create a second database.
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db1", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db1", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db1", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -6920,10 +6809,7 @@ func TestServer_WhereTimeInclusive(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -7030,10 +6916,7 @@ func TestServer_Query_ImplicitEndTime(t *testing.T) {
|
|||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.MetaClient.SetDefaultRetentionPolicy("db0", "rp0"); err != nil {
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicySpec("rp0", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,9 @@ type MetaClient interface {
|
|||
DropUser(name string) error
|
||||
RetentionPolicy(database, name string) (rpi *meta.RetentionPolicyInfo, err error)
|
||||
SetAdminPrivilege(username string, admin bool) error
|
||||
SetDefaultRetentionPolicy(database, name string) error
|
||||
SetPrivilege(username, database string, p influxql.Privilege) error
|
||||
ShardsByTimeRange(sources influxql.Sources, tmin, tmax time.Time) (a []meta.ShardInfo, err error)
|
||||
UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate) error
|
||||
UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error
|
||||
UpdateUser(name, password string) error
|
||||
UserPrivilege(username, database string) (*influxql.Privilege, error)
|
||||
UserPrivileges(username string) (map[string]influxql.Privilege, error)
|
||||
|
|
|
@ -30,10 +30,9 @@ type MetaClient struct {
|
|||
MetaNodesFn func() ([]meta.NodeInfo, error)
|
||||
RetentionPolicyFn func(database, name string) (rpi *meta.RetentionPolicyInfo, err error)
|
||||
SetAdminPrivilegeFn func(username string, admin bool) error
|
||||
SetDefaultRetentionPolicyFn func(database, name string) error
|
||||
SetPrivilegeFn func(username, database string, p influxql.Privilege) error
|
||||
ShardsByTimeRangeFn func(sources influxql.Sources, tmin, tmax time.Time) (a []meta.ShardInfo, err error)
|
||||
UpdateRetentionPolicyFn func(database, name string, rpu *meta.RetentionPolicyUpdate) error
|
||||
UpdateRetentionPolicyFn func(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error
|
||||
UpdateUserFn func(name, password string) error
|
||||
UserPrivilegeFn func(username, database string) (*influxql.Privilege, error)
|
||||
UserPrivilegesFn func(username string) (map[string]influxql.Privilege, error)
|
||||
|
@ -124,10 +123,6 @@ func (c *MetaClient) SetAdminPrivilege(username string, admin bool) error {
|
|||
return c.SetAdminPrivilegeFn(username, admin)
|
||||
}
|
||||
|
||||
func (c *MetaClient) SetDefaultRetentionPolicy(database, name string) error {
|
||||
return c.SetDefaultRetentionPolicyFn(database, name)
|
||||
}
|
||||
|
||||
func (c *MetaClient) SetPrivilege(username, database string, p influxql.Privilege) error {
|
||||
return c.SetPrivilegeFn(username, database, p)
|
||||
}
|
||||
|
@ -136,8 +131,8 @@ func (c *MetaClient) ShardsByTimeRange(sources influxql.Sources, tmin, tmax time
|
|||
return c.ShardsByTimeRangeFn(sources, tmin, tmax)
|
||||
}
|
||||
|
||||
func (c *MetaClient) UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate) error {
|
||||
return c.UpdateRetentionPolicyFn(database, name, rpu)
|
||||
func (c *MetaClient) UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error {
|
||||
return c.UpdateRetentionPolicyFn(database, name, rpu, makeDefault)
|
||||
}
|
||||
|
||||
func (c *MetaClient) UpdateUser(name, password string) error {
|
||||
|
|
|
@ -203,17 +203,9 @@ func (e *StatementExecutor) executeAlterRetentionPolicyStatement(stmt *influxql.
|
|||
}
|
||||
|
||||
// Update the retention policy.
|
||||
if err := e.MetaClient.UpdateRetentionPolicy(stmt.Database, stmt.Name, rpu); err != nil {
|
||||
if err := e.MetaClient.UpdateRetentionPolicy(stmt.Database, stmt.Name, rpu, stmt.Default); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If requested, set as default retention policy.
|
||||
if stmt.Default {
|
||||
if err := e.MetaClient.SetDefaultRetentionPolicy(stmt.Database, stmt.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -34,17 +34,16 @@ type MetaClientMock struct {
|
|||
|
||||
RetentionPolicyFn func(database, name string) (rpi *meta.RetentionPolicyInfo, err error)
|
||||
|
||||
SetAdminPrivilegeFn func(username string, admin bool) error
|
||||
SetDataFn func(*meta.Data) error
|
||||
SetDefaultRetentionPolicyFn func(database, name string) error
|
||||
SetPrivilegeFn func(username, database string, p influxql.Privilege) error
|
||||
ShardsByTimeRangeFn func(sources influxql.Sources, tmin, tmax time.Time) (a []meta.ShardInfo, err error)
|
||||
ShardOwnerFn func(shardID uint64) (database, policy string, sgi *meta.ShardGroupInfo)
|
||||
UpdateRetentionPolicyFn func(database, name string, rpu *meta.RetentionPolicyUpdate) error
|
||||
UpdateUserFn func(name, password string) error
|
||||
UserPrivilegeFn func(username, database string) (*influxql.Privilege, error)
|
||||
UserPrivilegesFn func(username string) (map[string]influxql.Privilege, error)
|
||||
UsersFn func() []meta.UserInfo
|
||||
SetAdminPrivilegeFn func(username string, admin bool) error
|
||||
SetDataFn func(*meta.Data) error
|
||||
SetPrivilegeFn func(username, database string, p influxql.Privilege) error
|
||||
ShardsByTimeRangeFn func(sources influxql.Sources, tmin, tmax time.Time) (a []meta.ShardInfo, err error)
|
||||
ShardOwnerFn func(shardID uint64) (database, policy string, sgi *meta.ShardGroupInfo)
|
||||
UpdateRetentionPolicyFn func(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error
|
||||
UpdateUserFn func(name, password string) error
|
||||
UserPrivilegeFn func(username, database string) (*influxql.Privilege, error)
|
||||
UserPrivilegesFn func(username string) (map[string]influxql.Privilege, error)
|
||||
UsersFn func() []meta.UserInfo
|
||||
}
|
||||
|
||||
func (c *MetaClientMock) Close() error {
|
||||
|
@ -123,10 +122,6 @@ func (c *MetaClientMock) SetAdminPrivilege(username string, admin bool) error {
|
|||
return c.SetAdminPrivilegeFn(username, admin)
|
||||
}
|
||||
|
||||
func (c *MetaClientMock) SetDefaultRetentionPolicy(database, name string) error {
|
||||
return c.SetDefaultRetentionPolicyFn(database, name)
|
||||
}
|
||||
|
||||
func (c *MetaClientMock) SetPrivilege(username, database string, p influxql.Privilege) error {
|
||||
return c.SetPrivilegeFn(username, database, p)
|
||||
}
|
||||
|
@ -139,8 +134,8 @@ func (c *MetaClientMock) ShardOwner(shardID uint64) (database, policy string, sg
|
|||
return c.ShardOwnerFn(shardID)
|
||||
}
|
||||
|
||||
func (c *MetaClientMock) UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate) error {
|
||||
return c.UpdateRetentionPolicyFn(database, name, rpu)
|
||||
func (c *MetaClientMock) UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error {
|
||||
return c.UpdateRetentionPolicyFn(database, name, rpu, makeDefault)
|
||||
}
|
||||
|
||||
func (c *MetaClientMock) UpdateUser(name, password string) error {
|
||||
|
|
|
@ -189,9 +189,6 @@ func (c *Client) CreateDatabase(name string) (*DatabaseInfo, error) {
|
|||
if err := data.CreateRetentionPolicy(name, rpi, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := data.SetDefaultRetentionPolicy(name, rpi.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
db := data.Database(name)
|
||||
|
@ -237,20 +234,18 @@ func (c *Client) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionP
|
|||
// policy we just created. If the default is different from what we are
|
||||
// trying to create, record it as a conflict and abandon with an error.
|
||||
if db.DefaultRetentionPolicy == "" {
|
||||
if err := data.SetDefaultRetentionPolicy(name, rpi.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db.DefaultRetentionPolicy = rpi.Name
|
||||
} else if rpi.Name != db.DefaultRetentionPolicy {
|
||||
return nil, ErrRetentionPolicyConflict
|
||||
}
|
||||
|
||||
// Refresh the database info.
|
||||
db = data.Database(name)
|
||||
|
||||
if err := c.commit(data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Refresh the database info.
|
||||
db = data.Database(name)
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
|
@ -326,32 +321,14 @@ func (c *Client) DropRetentionPolicy(database, name string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// SetDefaultRetentionPolicy sets a database's default retention policy.
|
||||
func (c *Client) SetDefaultRetentionPolicy(database, name string) error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
data := c.cacheData.Clone()
|
||||
|
||||
if err := data.SetDefaultRetentionPolicy(database, name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := c.commit(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateRetentionPolicy updates a retention policy.
|
||||
func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error {
|
||||
func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
data := c.cacheData.Clone()
|
||||
|
||||
if err := data.UpdateRetentionPolicy(database, name, rpu); err != nil {
|
||||
if err := data.UpdateRetentionPolicy(database, name, rpu, makeDefault); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ func TestMetaClient_CreateRetentionPolicy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestMetaClient_SetDefaultRetentionPolicy(t *testing.T) {
|
||||
func TestMetaClient_DefaultRetentionPolicy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
d, c := newClient()
|
||||
|
@ -402,7 +402,7 @@ func TestMetaClient_UpdateRetentionPolicy(t *testing.T) {
|
|||
if err := c.UpdateRetentionPolicy("db0", "rp0", &meta.RetentionPolicyUpdate{
|
||||
Duration: &duration,
|
||||
ReplicaN: &replicaN,
|
||||
}); err != nil {
|
||||
}, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ func TestMetaClient_UpdateRetentionPolicy(t *testing.T) {
|
|||
duration = rpi.ShardGroupDuration / 2
|
||||
if err := c.UpdateRetentionPolicy("db0", "rp0", &meta.RetentionPolicyUpdate{
|
||||
Duration: &duration,
|
||||
}); err == nil {
|
||||
}, true); err == nil {
|
||||
t.Fatal("expected error")
|
||||
} else if err != meta.ErrIncompatibleDurations {
|
||||
t.Fatalf("expected error '%s', got '%s'", meta.ErrIncompatibleDurations, err)
|
||||
|
@ -428,7 +428,7 @@ func TestMetaClient_UpdateRetentionPolicy(t *testing.T) {
|
|||
sgDuration := rpi.Duration * 2
|
||||
if err := c.UpdateRetentionPolicy("db0", "rp0", &meta.RetentionPolicyUpdate{
|
||||
ShardGroupDuration: &sgDuration,
|
||||
}); err == nil {
|
||||
}, true); err == nil {
|
||||
t.Fatal("expected error")
|
||||
} else if err != meta.ErrIncompatibleDurations {
|
||||
t.Fatalf("expected error '%s', got '%s'", meta.ErrIncompatibleDurations, err)
|
||||
|
@ -440,7 +440,7 @@ func TestMetaClient_UpdateRetentionPolicy(t *testing.T) {
|
|||
if err := c.UpdateRetentionPolicy("db0", "rp0", &meta.RetentionPolicyUpdate{
|
||||
Duration: &duration,
|
||||
ShardGroupDuration: &sgDuration,
|
||||
}); err == nil {
|
||||
}, true); err == nil {
|
||||
t.Fatal("expected error")
|
||||
} else if err != meta.ErrIncompatibleDurations {
|
||||
t.Fatalf("expected error '%s', got '%s'", meta.ErrIncompatibleDurations, err)
|
||||
|
@ -452,7 +452,7 @@ func TestMetaClient_UpdateRetentionPolicy(t *testing.T) {
|
|||
if err := c.UpdateRetentionPolicy("db0", "rp0", &meta.RetentionPolicyUpdate{
|
||||
Duration: &duration,
|
||||
ShardGroupDuration: &sgDuration,
|
||||
}); err != nil {
|
||||
}, true); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ func (rpu *RetentionPolicyUpdate) SetReplicaN(v int) { rpu.ReplicaN = &v }
|
|||
func (rpu *RetentionPolicyUpdate) SetShardGroupDuration(v time.Duration) { rpu.ShardGroupDuration = &v }
|
||||
|
||||
// UpdateRetentionPolicy updates an existing retention policy.
|
||||
func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error {
|
||||
func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error {
|
||||
// Find database.
|
||||
di := data.Database(database)
|
||||
if di == nil {
|
||||
|
@ -268,26 +268,10 @@ func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPol
|
|||
rpi.ShardGroupDuration = normalisedShardDuration(*rpu.ShardGroupDuration, rpi.Duration)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetDefaultRetentionPolicy sets the default retention policy for a database.
|
||||
func (data *Data) SetDefaultRetentionPolicy(database, name string) error {
|
||||
if name == "" {
|
||||
name = DefaultRetentionPolicyName
|
||||
if di.DefaultRetentionPolicy != rpi.Name && makeDefault {
|
||||
di.DefaultRetentionPolicy = rpi.Name
|
||||
}
|
||||
|
||||
// Find database and verify policy exists.
|
||||
di := data.Database(database)
|
||||
if di == nil {
|
||||
return influxdb.ErrDatabaseNotFound(database)
|
||||
} else if di.RetentionPolicy(name) == nil {
|
||||
return influxdb.ErrRetentionPolicyNotFound(name)
|
||||
}
|
||||
|
||||
// Set default policy.
|
||||
di.DefaultRetentionPolicy = name
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue