0
0
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:
Yakko Majuri 2022-04-26 16:58:30 +00:00 committed by GitHub
parent 63c783feb0
commit 4f41076aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 5 deletions

View File

@ -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' }}

View 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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -8,4 +8,5 @@ addopts = -p no:warnings --reuse-db
markers =
ee
clickhouse_only
skip_on_multitenancy
skip_on_multitenancy
async_migrations