Beispiel #1
0
    def test_database_handler_delete_policy(self):
        config = copy.deepcopy(self.db_config)
        config["desired_policies"].pop()

        main.process_database(config)

        self.client.drop_query.assert_any_call(
            "RETENTION POLICY \"rollup_20m\" ON \"test\""
        )
        self.client.other_query.assert_not_called()
        self.client.create_query.assert_not_called()
        self.client.alter_query.assert_not_called()
Beispiel #2
0
    def test_database_handler_update_policy(self):
        config = copy.deepcopy(self.db_config)
        config["desired_policies"][0]["retention"] = "25h0m0s"

        main.process_database(config)

        self.client.alter_query.assert_any_call(
            "RETENTION POLICY rollup_20m ON test DURATION 25h0m0s "
            "REPLICATION 1 SHARD DURATION 4h"
        )
        self.client.other_query.assert_not_called()
        self.client.create_query.assert_not_called()
        self.client.drop_query.assert_not_called()
Beispiel #3
0
 def test_database_handler_missing_policy(self):
     config = copy.deepcopy(self.db_config)
     config["desired_policies"].append({
         "rollup": "2m",
         "retention": "24h0m0s",
         "replication": 1,
         "shard_duration": "4h"
     })
     main.process_database(config)
     self.client.create_query.assert_any_call(
         "RETENTION POLICY rollup_2m ON test "
         "DURATION 24h0m0s REPLICATION 1 SHARD DURATION 4h"
     )
     self.client.create_query.assert_any_call(
         "CONTINUOUS QUERY test_measurement_rollup_2m ON test BEGIN "
         "SELECT mean(value) AS value, max(value) AS max_value, "
         "min(value) AS min_value INTO test.rollup_2m.test_measurement "
         "FROM test.input.test_measurement GROUP BY *, time(2m) END"
     )
     self.client.other_query.assert_not_called()
     self.client.alter_query.assert_not_called()
     self.client.drop_query.assert_not_called()
Beispiel #4
0
    def test_database_handler_alter_query(self):
        continuous_queries = copy.deepcopy(self.expected_query_result)
        continuous_queries[0]["query"] = "CREATE CONTINUOUS QUERY Needs update"

        self.client = make_client(
            measurements=copy.deepcopy(self.measurements),
            retention_policies=copy.deepcopy(self.expected_policy_result),
            continuous_queries=continuous_queries
        )
        self.patched_client.return_value = self.client

        main.process_database(copy.deepcopy(self.db_config))

        self.client.drop_query.assert_any_call(
            "CONTINUOUS QUERY test_measurement_rollup_20m ON test"
        )
        self.client.create_query.assert_any_call(
            "CONTINUOUS QUERY test_measurement_rollup_20m ON test "
            "BEGIN SELECT mean(value) AS value, max(value) AS max_value, "
            "min(value) AS min_value INTO test.rollup_20m.test_measurement "
            "FROM test.input.test_measurement GROUP BY *, time(20m) END"
        )
        self.client.other_query.assert_not_called()
        self.client.alter_query.assert_not_called()
Beispiel #5
0
 def test_database_handler(self):
     main.process_database(copy.deepcopy(self.db_config))
     self.client.other_query.assert_not_called()
     self.client.create_query.assert_not_called()
     self.client.drop_query.assert_not_called()
     self.client.alter_query.assert_not_called()