Skip to content

Commit 2a814b5

Browse files
committed
Add integration tests
1 parent 92d4a41 commit 2a814b5

File tree

2 files changed

+492
-0
lines changed

2 files changed

+492
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
from linode_api4 import LinodeClient
2+
from linode_api4.objects import (
3+
MySQLDatabase,
4+
MySQLDatabaseConfigMySQLOptions,
5+
MySQLDatabaseConfigOptions,
6+
PostgreSQLDatabase,
7+
PostgreSQLDatabaseConfigOptions,
8+
PostgreSQLDatabaseConfigPGOptions,
9+
)
10+
11+
12+
# Test Helpers
13+
def get_db_engine_id(client: LinodeClient, engine: str):
14+
engines = client.database.engines()
15+
engine_id = ""
16+
for e in engines:
17+
if e.engine == engine:
18+
engine_id = e.id
19+
20+
return str(engine_id)
21+
22+
23+
def get_sql_db_status(client: LinodeClient, db_id, status: str):
24+
db = client.load(MySQLDatabase, db_id)
25+
return db.status == status
26+
27+
28+
def get_postgres_db_status(client: LinodeClient, db_id, status: str):
29+
db = client.load(PostgreSQLDatabase, db_id)
30+
return db.status == status
31+
32+
33+
def make_full_mysql_engine_config():
34+
return MySQLDatabaseConfigOptions(
35+
binlog_retention_period=600,
36+
mysql=MySQLDatabaseConfigMySQLOptions(
37+
connect_timeout=20,
38+
default_time_zone="+00:00",
39+
group_concat_max_len=1024,
40+
information_schema_stats_expiry=900,
41+
innodb_change_buffer_max_size=25,
42+
innodb_flush_neighbors=1,
43+
innodb_ft_min_token_size=3,
44+
innodb_ft_server_stopword_table="db_name/table_name",
45+
innodb_lock_wait_timeout=50,
46+
innodb_log_buffer_size=16777216,
47+
innodb_online_alter_log_max_size=134217728,
48+
innodb_read_io_threads=4,
49+
innodb_rollback_on_timeout=True,
50+
innodb_thread_concurrency=8,
51+
innodb_write_io_threads=4,
52+
interactive_timeout=300,
53+
internal_tmp_mem_storage_engine="TempTable",
54+
max_allowed_packet=67108864,
55+
max_heap_table_size=16777216,
56+
net_buffer_length=16384,
57+
net_read_timeout=30,
58+
net_write_timeout=60,
59+
sort_buffer_size=262144,
60+
sql_mode="TRADITIONAL",
61+
sql_require_primary_key=False,
62+
tmp_table_size=16777216,
63+
wait_timeout=28800,
64+
),
65+
)
66+
67+
68+
def make_full_postgres_engine_config():
69+
return PostgreSQLDatabaseConfigOptions(
70+
pg=PostgreSQLDatabaseConfigPGOptions(
71+
autovacuum_analyze_scale_factor=0.1,
72+
autovacuum_analyze_threshold=50,
73+
autovacuum_max_workers=3,
74+
autovacuum_naptime=60,
75+
autovacuum_vacuum_cost_delay=20,
76+
autovacuum_vacuum_cost_limit=200,
77+
autovacuum_vacuum_scale_factor=0.2,
78+
autovacuum_vacuum_threshold=50,
79+
bgwriter_delay=200,
80+
bgwriter_flush_after=64,
81+
bgwriter_lru_maxpages=100,
82+
bgwriter_lru_multiplier=2.0,
83+
deadlock_timeout=1000,
84+
default_toast_compression="lz4",
85+
idle_in_transaction_session_timeout=600000,
86+
jit=True,
87+
max_files_per_process=1000,
88+
max_locks_per_transaction=64,
89+
max_logical_replication_workers=4,
90+
max_parallel_workers=4,
91+
max_parallel_workers_per_gather=2,
92+
max_pred_locks_per_transaction=64,
93+
max_replication_slots=10,
94+
max_slot_wal_keep_size=2048,
95+
max_stack_depth=6291456,
96+
max_standby_archive_delay=30000,
97+
max_standby_streaming_delay=30000,
98+
max_wal_senders=20,
99+
max_worker_processes=8,
100+
password_encryption="scram-sha-256",
101+
temp_file_limit=1,
102+
timezone="UTC",
103+
track_activity_query_size=2048,
104+
track_functions="all",
105+
wal_sender_timeout=60000,
106+
wal_writer_delay=200,
107+
),
108+
pg_stat_monitor_enable=True,
109+
shared_buffers_percentage=25.0,
110+
work_mem=1024,
111+
)

0 commit comments

Comments
 (0)