Add a test for the shard expiration
parent
22d02b734d
commit
adfbdb0e4e
|
@ -147,6 +147,47 @@ func (self *ServerSuite) TestGraphiteUdpInterface(c *C) {
|
||||||
c.Assert(series.GetValueForPointAndColumn(1, "value", c), Equals, 100.0)
|
c.Assert(series.GetValueForPointAndColumn(1, "value", c), Equals, 100.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ServerSuite) TestShardExpiration(c *C) {
|
||||||
|
// makes sure when a shard expires due to retention policy the data
|
||||||
|
// is deleted as well as the metadata
|
||||||
|
|
||||||
|
client := self.serverProcesses[0].GetClient("", c)
|
||||||
|
client.CreateDatabase("db1")
|
||||||
|
space := &influxdb.ShardSpace{Name: "short", RetentionPolicy: "5s", Database: "db1", Regex: "/^test_shard_expiration/"}
|
||||||
|
err := client.CreateShardSpace(space)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
|
self.serverProcesses[0].WriteData(`
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "test_shard_expiration",
|
||||||
|
"columns": ["time", "val"],
|
||||||
|
"points":[[1307997668000, 1]]
|
||||||
|
}
|
||||||
|
]`, c)
|
||||||
|
|
||||||
|
// Make sure the shard exists
|
||||||
|
shards, err := client.GetShards()
|
||||||
|
shardsInSpace := filterShardsInSpace("short", shards.All)
|
||||||
|
c.Assert(shardsInSpace, HasLen, 1)
|
||||||
|
|
||||||
|
time.Sleep(6 * time.Second)
|
||||||
|
|
||||||
|
// Make sure the shard is gone
|
||||||
|
shards, err = client.GetShards()
|
||||||
|
shardsInSpace = filterShardsInSpace("short", shards.All)
|
||||||
|
c.Assert(shardsInSpace, HasLen, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func filterShardsInSpace(spaceName string, shards []*influxdb.Shard) (filteredShards []*influxdb.Shard) {
|
||||||
|
for _, s := range shards {
|
||||||
|
if s.SpaceName == spaceName {
|
||||||
|
filteredShards = append(filteredShards, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (self *ServerSuite) TestRestartAfterCompaction(c *C) {
|
func (self *ServerSuite) TestRestartAfterCompaction(c *C) {
|
||||||
data := `
|
data := `
|
||||||
[{
|
[{
|
||||||
|
|
|
@ -50,6 +50,8 @@ dir = "/tmp/influxdb/test/1/raft"
|
||||||
[storage]
|
[storage]
|
||||||
dir = "/tmp/influxdb/test/1/db"
|
dir = "/tmp/influxdb/test/1/db"
|
||||||
|
|
||||||
|
retention-sweep-period = "1s"
|
||||||
|
|
||||||
[cluster]
|
[cluster]
|
||||||
# A comma separated list of servers to seed
|
# A comma separated list of servers to seed
|
||||||
# this server. this is only relevant when the
|
# this server. this is only relevant when the
|
||||||
|
|
|
@ -34,6 +34,8 @@ dir = "/tmp/influxdb/test/2/raft"
|
||||||
[storage]
|
[storage]
|
||||||
dir = "/tmp/influxdb/test/2/db"
|
dir = "/tmp/influxdb/test/2/db"
|
||||||
|
|
||||||
|
retention-sweep-period = "1s"
|
||||||
|
|
||||||
[cluster]
|
[cluster]
|
||||||
# A comma separated list of servers to seed
|
# A comma separated list of servers to seed
|
||||||
# this server. this is only relevant when the
|
# this server. this is only relevant when the
|
||||||
|
|
|
@ -34,6 +34,8 @@ dir = "/tmp/influxdb/test/3/raft"
|
||||||
[storage]
|
[storage]
|
||||||
dir = "/tmp/influxdb/test/3/db"
|
dir = "/tmp/influxdb/test/3/db"
|
||||||
|
|
||||||
|
retention-sweep-period = "1s"
|
||||||
|
|
||||||
[cluster]
|
[cluster]
|
||||||
# A comma separated list of servers to seed
|
# A comma separated list of servers to seed
|
||||||
# this server. this is only relevant when the
|
# this server. this is only relevant when the
|
||||||
|
|
|
@ -73,6 +73,9 @@ dir = "/tmp/influxdb/development/raft"
|
||||||
|
|
||||||
[storage]
|
[storage]
|
||||||
|
|
||||||
|
# The server will check this often for shards that have expired and should be cleared.
|
||||||
|
retention-sweep-period = "10s"
|
||||||
|
|
||||||
dir = "/tmp/influxdb/development/db"
|
dir = "/tmp/influxdb/development/db"
|
||||||
# How many requests to potentially buffer in memory. If the buffer gets filled then writes
|
# How many requests to potentially buffer in memory. If the buffer gets filled then writes
|
||||||
# will still be logged and once the local storage has caught up (or compacted) the writes
|
# will still be logged and once the local storage has caught up (or compacted) the writes
|
||||||
|
|
|
@ -47,6 +47,10 @@ port = 60501
|
||||||
dir = "/tmp/influxdb/test/1/raft"
|
dir = "/tmp/influxdb/test/1/raft"
|
||||||
|
|
||||||
[storage]
|
[storage]
|
||||||
|
|
||||||
|
# The server will check this often for shards that have expired and should be cleared.
|
||||||
|
retention-sweep-period = "10s"
|
||||||
|
|
||||||
dir = "/tmp/influxdb/test/1/db"
|
dir = "/tmp/influxdb/test/1/db"
|
||||||
|
|
||||||
[cluster]
|
[cluster]
|
||||||
|
|
|
@ -32,6 +32,10 @@ port = 60507
|
||||||
dir = "/tmp/influxdb/test/2/raft"
|
dir = "/tmp/influxdb/test/2/raft"
|
||||||
|
|
||||||
[storage]
|
[storage]
|
||||||
|
|
||||||
|
# The server will check this often for shards that have expired and should be cleared.
|
||||||
|
retention-sweep-period = "10s"
|
||||||
|
|
||||||
dir = "/tmp/influxdb/test/2/db"
|
dir = "/tmp/influxdb/test/2/db"
|
||||||
|
|
||||||
[cluster]
|
[cluster]
|
||||||
|
|
Loading…
Reference in New Issue