Cleanup Spanner Test Infra #472
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2024 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Cleanup Spanner Test Infra | |
| on: | |
| schedule: | |
| - cron: "0 4 * * *" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| cleanup: | |
| name: Cleanup main project | |
| runs-on: [self-hosted, it] | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r test-infra/requirements.txt | |
| - name: Run cleanup_pubsub_notifications.py | |
| # There could be pubsub notifications created by tests other than Spanner tests and hence not removing and | |
| # keeping the pubsub notification cleanup on the main project. | |
| run: python test-infra/cleanup_pubsub_notifications.py --project cloud-teleport-testing | |
| - name: Run cleanup_spanner_databases.py | |
| # The Spanner databases are created in Spanner Import/Export tests which are in the main project and not moved | |
| # to the new project and hence not removing and keeping the spanner database cleanup on the main project. | |
| run: python test-infra/cleanup_spanner_databases.py --project cloud-teleport-testing | |
| - name: Run delete_spanner_instances.sh | |
| run: bash test-infra/delete_spanner_instances.sh | |
| - name: Run cleanup_datastream_resources.py | |
| # Look back period for cloud-teleport-testing is 5 days since the load tests can run upto 3 days + including some buffer. | |
| run: python test-infra/cleanup_datastream_resources.py --project cloud-teleport-testing --look_back_period 5 | |
| cleanup_spanner_project: | |
| name: Cleanup spanner project | |
| runs-on: [self-hosted, spanner-it] | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r test-infra/requirements.txt | |
| - name: Run cleanup_pubsub_notifications.py | |
| run: python test-infra/cleanup_pubsub_notifications.py --project span-cloud-teleport-testing | |
| - name: Run cleanup_spanner_databases.py | |
| run: python test-infra/cleanup_spanner_databases.py --project span-cloud-teleport-testing | |
| - name: Run cleanup_datastream_resources.py | |
| # Look back period for span-cloud-teleport-testing is 1 day since we only run Integration tests in that project which execute in the order of hours. | |
| run: python test-infra/cleanup_datastream_resources.py --project span-cloud-teleport-testing --look_back_period 1 |