mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 09:16:49 +01:00
e96f95ef5a
* Add Postgres model PluginLogEntry * Add equivalent PluginLogEntry to Kafka+ClickHouse * Add migration * Add PluginLogEntry.Type.LOG & make PluginLogEntry.message a TextField * Update 0130_pluginlogentry.py * Add PluginLogEntry.instance_id * Update migration * Update migration * Add plugin log entries API * Test plugin log entries DB fetching * Add PluginLogs component prototype * Fix API * Improve PluginLogs component * Remove almost unused plugin Feedback button * Update migration * Fixed typing * Fix org permission error test asserts * Fix plugin log entry tests * Fix CH plugin log entry timestamp string * Update CH test_plugin_log_entry.py * Fix plugin log entry tests across PG/CH * Satisfy mypy * Add search and limit to plugin log entry API * Send team_id in plugin config API * Rework plugin logs UI * Add plugin config team ID in tests * Add plugin config team ID in tests actually * Fix code quality * Make logs plugin config-based * Fix CH queries * Fix typing * Improve UX and fix things * Polish plugin logs logic * Update migration * Add Celery task to delete old plugin logs * Fix UX bug with loading more plugin logs * Fix missing import * Remove OrganizationMemberPermissions message change * Make mypy happy * Add PluginLogEntry.is_system * Optimize CH plugin_log_entires PARTITION/ORDER * Increment migration * Adjust plugin logs drawer display * Fix plugin_log_factory_ch * Fix plugin_log_factory_ch fix * Replace PluginLogEntry.is_system with source * Adjust PluginLogEntrySerializer * Update CH fetch_plugin_log_entries * Make kea-typegen happy
103 lines
2.8 KiB
Python
103 lines
2.8 KiB
Python
import pytest
|
|
from infi.clickhouse_orm import Database
|
|
|
|
from ee.clickhouse.client import sync_execute
|
|
from ee.clickhouse.sql.plugin_log_entries import DROP_PLUGIN_LOG_ENTRIES_TABLE_SQL, PLUGIN_LOG_ENTRIES_TABLE_SQL
|
|
from posthog.settings import (
|
|
CLICKHOUSE_DATABASE,
|
|
CLICKHOUSE_HTTP_URL,
|
|
CLICKHOUSE_PASSWORD,
|
|
CLICKHOUSE_USER,
|
|
CLICKHOUSE_VERIFY,
|
|
)
|
|
from posthog.test.base import TestMixin
|
|
|
|
|
|
@pytest.fixture(scope="package")
|
|
def django_db_setup(django_db_setup, django_db_keepdb):
|
|
database = Database(
|
|
CLICKHOUSE_DATABASE,
|
|
db_url=CLICKHOUSE_HTTP_URL,
|
|
username=CLICKHOUSE_USER,
|
|
password=CLICKHOUSE_PASSWORD,
|
|
verify_ssl_cert=CLICKHOUSE_VERIFY,
|
|
)
|
|
|
|
if not django_db_keepdb:
|
|
try:
|
|
database.drop_database()
|
|
except:
|
|
pass
|
|
|
|
if not django_db_keepdb or not database.db_exists:
|
|
database.create_database()
|
|
|
|
database.migrate("ee.clickhouse.migrations")
|
|
# Make DELETE / UPDATE synchronous to avoid flaky tests
|
|
sync_execute("SET mutations_sync = 1")
|
|
|
|
yield
|
|
|
|
if not django_db_keepdb:
|
|
try:
|
|
database.drop_database()
|
|
except:
|
|
pass
|
|
|
|
|
|
@pytest.fixture
|
|
def db(db):
|
|
from ee.clickhouse.sql.events import (
|
|
DROP_EVENTS_TABLE_SQL,
|
|
DROP_EVENTS_WITH_ARRAY_PROPS_TABLE_SQL,
|
|
EVENTS_TABLE_SQL,
|
|
EVENTS_WITH_PROPS_TABLE_SQL,
|
|
)
|
|
from ee.clickhouse.sql.person import (
|
|
DROP_PERSON_DISTINCT_ID_TABLE_SQL,
|
|
DROP_PERSON_STATIC_COHORT_TABLE_SQL,
|
|
DROP_PERSON_TABLE_SQL,
|
|
PERSON_STATIC_COHORT_TABLE_SQL,
|
|
PERSONS_DISTINCT_ID_TABLE_SQL,
|
|
PERSONS_TABLE_SQL,
|
|
)
|
|
from ee.clickhouse.sql.session_recording_events import (
|
|
DROP_SESSION_RECORDING_EVENTS_TABLE_SQL,
|
|
SESSION_RECORDING_EVENTS_TABLE_SQL,
|
|
)
|
|
|
|
yield
|
|
|
|
try:
|
|
sync_execute(DROP_EVENTS_TABLE_SQL)
|
|
sync_execute(DROP_EVENTS_WITH_ARRAY_PROPS_TABLE_SQL)
|
|
sync_execute(DROP_PERSON_TABLE_SQL)
|
|
sync_execute(DROP_PERSON_DISTINCT_ID_TABLE_SQL)
|
|
sync_execute(DROP_PERSON_STATIC_COHORT_TABLE_SQL)
|
|
sync_execute(DROP_SESSION_RECORDING_EVENTS_TABLE_SQL)
|
|
sync_execute(DROP_PLUGIN_LOG_ENTRIES_TABLE_SQL)
|
|
|
|
sync_execute(EVENTS_TABLE_SQL)
|
|
sync_execute(EVENTS_WITH_PROPS_TABLE_SQL)
|
|
sync_execute(SESSION_RECORDING_EVENTS_TABLE_SQL)
|
|
sync_execute(PERSONS_TABLE_SQL)
|
|
sync_execute(PERSONS_DISTINCT_ID_TABLE_SQL)
|
|
sync_execute(PERSON_STATIC_COHORT_TABLE_SQL)
|
|
sync_execute(PLUGIN_LOG_ENTRIES_TABLE_SQL)
|
|
except:
|
|
pass
|
|
|
|
|
|
@pytest.fixture
|
|
def base_test_mixin_fixture():
|
|
kls = TestMixin()
|
|
kls.setUp()
|
|
kls.setUpTestData()
|
|
|
|
return kls
|
|
|
|
|
|
@pytest.fixture
|
|
def team(base_test_mixin_fixture):
|
|
return base_test_mixin_fixture.team
|