mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-21 21:49:51 +01:00
chore: split out async migrations ci (#9539)
* chore: split out async migrations ci * update * mark test correctly * remove if from runner
This commit is contained in:
parent
63c783feb0
commit
4f41076aca
2
.github/actions/run-backend-tests/action.yml
vendored
2
.github/actions/run-backend-tests/action.yml
vendored
@ -82,7 +82,7 @@ runs:
|
||||
if: ${{ inputs.foss == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
pytest -m "not ee" posthog/ --cov --cov-report=xml:coverage-postgres.xml
|
||||
pytest -m "not ee and not async_migrations" posthog/ --cov --cov-report=xml:coverage-postgres.xml
|
||||
|
||||
- name: Run ee/ tests
|
||||
if: ${{ inputs.ee == 'true' }}
|
||||
|
83
.github/workflows/ci-async-migrations.yml
vendored
Normal file
83
.github/workflows/ci-async-migrations.yml
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
name: Async Migrations CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'posthog/async_migrations/**'
|
||||
- 'ee/clickhouse/sql/**'
|
||||
- 'ee/clickhouse/migrations/**'
|
||||
- 'ee/migrations/**'
|
||||
|
||||
env:
|
||||
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
|
||||
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
|
||||
REDIS_URL: 'redis://localhost'
|
||||
CLICKHOUSE_HOST: 'localhost'
|
||||
CLICKHOUSE_SECURE: 'False'
|
||||
CLICKHOUSE_VERIFY: 'False'
|
||||
TEST: 1
|
||||
CLICKHOUSE_SERVER_IMAGE_VERSION: ${{ github.event.inputs.clickhouseServerVersion || '' }}
|
||||
|
||||
jobs:
|
||||
async-migrations:
|
||||
name: Async Migrations tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout repo'
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Start stack with Docker Compose
|
||||
shell: bash
|
||||
run: |
|
||||
export CLICKHOUSE_SERVER_IMAGE_VERSION=${{ inputs.clickhouse-server-image-version }}
|
||||
docker-compose -f docker-compose.dev.yml down
|
||||
docker-compose -f docker-compose.dev.yml up -d db clickhouse zookeeper kafka redis &
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ inputs.python-version }}
|
||||
|
||||
- name: Install SAML (python3-saml) dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
|
||||
|
||||
- uses: syphar/restore-virtualenv@v1.2
|
||||
id: cache-async-migrations-tests
|
||||
with:
|
||||
custom_cache_key_element: v1-${{ inputs.cache-id }}
|
||||
|
||||
- uses: syphar/restore-pip-download-cache@v1
|
||||
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
||||
|
||||
- name: Install python dependencies
|
||||
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install -r requirements-dev.txt
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
- name: Add kafka host to /etc/hosts for kafka connectivity
|
||||
shell: bash
|
||||
run: sudo echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts
|
||||
|
||||
- name: Set up needed files
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p frontend/dist
|
||||
touch frontend/dist/index.html
|
||||
touch frontend/dist/layout.html
|
||||
touch frontend/dist/shared_dashboard.html
|
||||
|
||||
- name: Wait for Clickhouse & Kafka
|
||||
shell: bash
|
||||
run: bin/check_kafka_clickhouse_up
|
||||
|
||||
- name: Run async migrations tests
|
||||
shell: bash
|
||||
run: |
|
||||
pytest -m "async_migrations" posthog/ --cov --cov-report=xml:coverage-postgres.xml
|
2
.github/workflows/ci-backend.yml
vendored
2
.github/workflows/ci-backend.yml
vendored
@ -313,4 +313,4 @@ jobs:
|
||||
run: |
|
||||
source .env.template
|
||||
cd deploy
|
||||
pytest multi_tenancy messaging -m "not skip_on_multitenancy"
|
||||
pytest multi_tenancy messaging -m "not skip_on_multitenancy and not async_migrations"
|
||||
|
@ -87,7 +87,7 @@ class Test0002EventsSampleBy(AsyncMigrationBaseTest):
|
||||
execute_query(f"DROP TABLE {CLICKHOUSE_DATABASE}.events")
|
||||
|
||||
# Run the full migration through
|
||||
@pytest.mark.ee
|
||||
@pytest.mark.async_migrations
|
||||
def test_run_migration_in_full(self):
|
||||
from posthog.client import sync_execute
|
||||
|
||||
|
@ -21,6 +21,7 @@ class Test0003FillPersonDistinctId2(AsyncMigrationBaseTest):
|
||||
sync_execute("TRUNCATE TABLE person_distinct_id2")
|
||||
sync_execute("ALTER TABLE person_distinct_id COMMENT COLUMN distinct_id 'dont_skip_0003'")
|
||||
|
||||
@pytest.mark.async_migrations
|
||||
def test_is_required(self):
|
||||
from posthog.client import sync_execute
|
||||
|
||||
@ -29,6 +30,7 @@ class Test0003FillPersonDistinctId2(AsyncMigrationBaseTest):
|
||||
sync_execute("ALTER TABLE person_distinct_id COMMENT COLUMN distinct_id 'skip_0003_fill_person_distinct_id2'")
|
||||
self.assertFalse(self.migration.is_required())
|
||||
|
||||
@pytest.mark.async_migrations
|
||||
def test_migration(self):
|
||||
from posthog.client import sync_execute
|
||||
|
||||
|
@ -28,7 +28,6 @@ def _create_event(**kwargs):
|
||||
create_event(**kwargs)
|
||||
|
||||
|
||||
@pytest.mark.ee
|
||||
class Test0004ReplicatedSchema(AsyncMigrationBaseTest, ClickhouseTestMixin):
|
||||
def setUp(self):
|
||||
self.recreate_database()
|
||||
@ -49,6 +48,7 @@ class Test0004ReplicatedSchema(AsyncMigrationBaseTest, ClickhouseTestMixin):
|
||||
sync_execute(f"CREATE DATABASE {settings.CLICKHOUSE_DATABASE}")
|
||||
create_clickhouse_tables(0)
|
||||
|
||||
@pytest.mark.async_migrations
|
||||
def test_is_required(self):
|
||||
from posthog.client import sync_execute
|
||||
|
||||
@ -61,6 +61,7 @@ class Test0004ReplicatedSchema(AsyncMigrationBaseTest, ClickhouseTestMixin):
|
||||
sync_execute(DISTRIBUTED_EVENTS_TABLE_SQL())
|
||||
self.assertFalse(migration.is_required())
|
||||
|
||||
@pytest.mark.async_migrations
|
||||
def test_migration(self):
|
||||
# :TRICKY: Relies on tables being migrated as unreplicated before.
|
||||
|
||||
@ -83,6 +84,7 @@ class Test0004ReplicatedSchema(AsyncMigrationBaseTest, ClickhouseTestMixin):
|
||||
)
|
||||
self.assertEqual(self.get_event_table_row_count(), 2)
|
||||
|
||||
@pytest.mark.async_migrations
|
||||
def test_rollback(self):
|
||||
# :TRICKY: Relies on tables being migrated as unreplicated before.
|
||||
|
||||
|
@ -8,4 +8,5 @@ addopts = -p no:warnings --reuse-db
|
||||
markers =
|
||||
ee
|
||||
clickhouse_only
|
||||
skip_on_multitenancy
|
||||
skip_on_multitenancy
|
||||
async_migrations
|
Loading…
Reference in New Issue
Block a user