Skip to content

Commit

Permalink
Merge pull request #7449 from influxdata/cjl-7488-fix-rp-defaults
Browse files Browse the repository at this point in the history
fix retention policy creation inconsistencies
  • Loading branch information
corylanou authored Nov 7, 2016
2 parents 4b85371 + 6e29004 commit 40f626d
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 333 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The query language has been extended with a few new features:
- [#7526](https://github.com/influxdata/influxdb/issues/7526): Truncate the version string when linking to the documentation.
- [#7548](https://github.com/influxdata/influxdb/issues/7548): Fix output duration units for SHOW QUERIES.
- [#7564](https://github.com/influxdata/influxdb/issues/7564): Fix incorrect grouping when multiple aggregates are used with sparse data.
- [#7448](https://github.com/influxdata/influxdb/pull/7448): Fix Retention Policy Inconsistencies

## v1.0.2 [2016-10-05]

Expand Down
5 changes: 1 addition & 4 deletions cmd/influxd/run/backup_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
15 changes: 4 additions & 11 deletions cmd/influxd/run/server_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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); err != nil {
} else if _, err := s.MetaClient.CreateRetentionPolicy(db, rp, makeDefault); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions cmd/influxd/run/server_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ func init() {
exp: `{"results":[{}]}`,
once: true,
},
&Query{
name: "create retention policy with default on",
command: `CREATE RETENTION POLICY rp3 ON db0 DURATION 1h REPLICATION 1 SHARD DURATION 30m DEFAULT`,
exp: `{"results":[{"error":"retention policy conflicts with an existing policy"}]}`,
once: true,
},
&Query{
name: "show retention policy should show both with custom shard",
command: `SHOW RETENTION POLICIES ON db0`,
Expand Down
Loading

0 comments on commit 40f626d

Please sign in to comment.