diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1428628d2..f1fb1d376 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,8 +33,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -89,22 +87,20 @@ jobs: include: # don't run against the following C* versions when using cassandra storage type - cassandra-version: 1.2.19 - cucumber-options: '--tags ~@cassandra_2_1_onwards --tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_2_1_onwards --tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 2.0.17 - cucumber-options: '--tags ~@cassandra_2_1_onwards --tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_2_1_onwards --tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 2.1.22 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 2.2.19 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.0.24 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.11.10 cucumber-options: '--tags ~@cassandra_4_0_onwards' steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -166,18 +162,6 @@ jobs: name: Postgres backend needs: build runs-on: ubuntu-20.04 - services: - postgres: - image: postgres:9.4 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - # this replaces the manual reaper creation - POSTGRES_DB: reaper - ports: - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 strategy: matrix: cassandra-version: [3.11.10] @@ -206,8 +190,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -238,6 +220,10 @@ jobs: python-version: '3.x' architecture: 'x64' + - name: Setup postgres DB + run: + docker run --name posttest -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=reaper postgres:alpine -c max_connections=300 + - name: Install CCM run: | pip install pyyaml @@ -276,12 +262,18 @@ jobs: cassandra-version: [2.1.22, 2.2.19, 3.0.24, 3.11.10, 'github:apache/trunk'] storage-type: [cassandra] test-type: [ccm] - cucumber-options: ['--tags ~@cassandra_4_0_onwards'] + include: + - cassandra-version: 2.1.22 + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' + - cassandra-version: 2.2.19 + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' + - cassandra-version: 3.0.24 + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' + - cassandra-version: 3.11.10 + cucumber-options: '--tags ~@cassandra_4_0_onwards' steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -354,8 +346,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -415,18 +405,6 @@ jobs: needs: [its-ccm-local, its-pgsql, its-ccm-cass, its-elassandra] name: Sidecar runs-on: ubuntu-20.04 - services: - postgres: - image: postgres:9.4 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - # this replaces the manual reaper creation - POSTGRES_DB: reaper - ports: - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 strategy: matrix: cassandra-version: [2.1.22, 2.2.19, 3.0.24, 3.11.10, 'github:apache/trunk'] @@ -437,11 +415,11 @@ jobs: # all versions but trunk have the same cucumber options, but we can't declare that more effectively (yet) include: - cassandra-version: 2.1.22 - cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar --tags ~@cassandra_3_11_onwards' - cassandra-version: 2.2.19 - cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.0.24 - cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.11.10 cucumber-options: '--tags ~@cassandra_4_0_onwards --tags @sidecar' - cassandra-version: 'github:apache/trunk' @@ -459,8 +437,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -490,6 +466,10 @@ jobs: python-version: '3.x' architecture: 'x64' + - name: Setup postgres DB + run: + docker run --name posttest -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=reaper postgres:alpine -c max_connections=300 + - name: Install CCM run: | pip install pyyaml @@ -550,8 +530,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -619,18 +597,16 @@ jobs: include: # all versions but trunk need to exclude trunk tests - cassandra-version: 2.1.22 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 2.2.19 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.0.24 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.11.10 cucumber-options: '--tags ~@cassandra_4_0_onwards' steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -700,18 +676,16 @@ jobs: include: # all versions but trunk need to exclude trunk tests - cassandra-version: 2.1.22 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 2.2.19 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.0.24 - cucumber-options: '--tags ~@cassandra_4_0_onwards' + cucumber-options: '--tags ~@cassandra_4_0_onwards --tags ~@cassandra_3_11_onwards' - cassandra-version: 3.11.10 cucumber-options: '--tags ~@cassandra_4_0_onwards' steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -782,8 +756,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 @@ -847,8 +819,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: master - name: Setup Maven Cache uses: actions/cache@v2 diff --git a/src/server/src/main/java/io/cassandrareaper/storage/PostgresStorage.java b/src/server/src/main/java/io/cassandrareaper/storage/PostgresStorage.java index 15c192e00..694aef947 100644 --- a/src/server/src/main/java/io/cassandrareaper/storage/PostgresStorage.java +++ b/src/server/src/main/java/io/cassandrareaper/storage/PostgresStorage.java @@ -943,7 +943,7 @@ public void purgeMetrics() { Instant expirationTime = getExpirationTime(metricsTimeout); storage.purgeOldMetrics(expirationTime); storage.purgeOldSourceNodes(expirationTime); - storage.purgeOldPercentRepairMetrics(Instant.ofEpochMilli(DateTime.now().minusDays(1).getMillis())); + storage.purgeOldPercentRepairMetrics(expirationTime); } } } diff --git a/src/server/src/main/java/io/cassandrareaper/storage/postgresql/IStoragePostgreSql.java b/src/server/src/main/java/io/cassandrareaper/storage/postgresql/IStoragePostgreSql.java index e296bca68..199d73e84 100644 --- a/src/server/src/main/java/io/cassandrareaper/storage/postgresql/IStoragePostgreSql.java +++ b/src/server/src/main/java/io/cassandrareaper/storage/postgresql/IStoragePostgreSql.java @@ -958,8 +958,8 @@ Collection getPercentRepairedMetrics( @Bind("since") Instant since ); - @SqlQuery(SQL_PURGE_PERCENT_REPAIRED) - void purgeOldPercentRepairMetrics( + @SqlUpdate(SQL_PURGE_PERCENT_REPAIRED) + int purgeOldPercentRepairMetrics( @Bind("expirationTime") Instant expirationTime ); } diff --git a/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java b/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java index c2171d681..c1c4c3b6e 100644 --- a/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java +++ b/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java @@ -2038,7 +2038,7 @@ private static boolean isInstanceOfDistributedStorage(String storageClassname) { public void percentRepairedMetricsGetCollectedForTheExistingSchedule() { synchronized (BasicSteps.class) { CLIENTS.parallelStream().forEach(client -> { - await().with().pollInterval(POLL_INTERVAL).atMost(3, MINUTES).until(() -> { + await().with().pollInterval(POLL_INTERVAL).atMost(5, MINUTES).until(() -> { try { List schedules = client.getRepairSchedulesForCluster(TestContext.TEST_CLUSTER); callAndExpect( diff --git a/src/server/src/test/resources/io.cassandrareaper.acceptance/integration_reaper_functionality.feature b/src/server/src/test/resources/io.cassandrareaper.acceptance/integration_reaper_functionality.feature index 26d669866..1afa68cb6 100644 --- a/src/server/src/test/resources/io.cassandrareaper.acceptance/integration_reaper_functionality.feature +++ b/src/server/src/test/resources/io.cassandrareaper.acceptance/integration_reaper_functionality.feature @@ -138,6 +138,25 @@ Feature: Using Reaper Then reaper has 1 scheduled repairs for cluster called "test" When reaper is upgraded to latest Then reaper has 1 scheduled repairs for cluster called "test" + And deleting cluster called "test" fails + When all added schedules are deleted for the last added cluster + And the last added cluster is deleted + Then reaper has no longer the last added cluster in storage + ${cucumber.upgrade-versions} + + @sidecar + @all_nodes_reachable + @cassandra_3_11_onwards + Scenario Outline: Add a scheduled incremental repair and collect percent repaired metrics + Given that reaper is running + And reaper has no cluster in storage + When an add-cluster request is made to reaper + Then reaper has the last added cluster in storage + And reaper has 0 scheduled repairs for cluster called "test" + When a new daily "incremental" repair schedule is added for "test" and keyspace "test_keyspace3" + Then reaper has 1 scheduled repairs for cluster called "test" + When reaper is upgraded to latest + Then reaper has 1 scheduled repairs for cluster called "test" And percent repaired metrics get collected for the existing schedule And deleting cluster called "test" fails When all added schedules are deleted for the last added cluster