Skip to content

Commit bfa76a7

Browse files
Added integration tests for suspend and resume
1 parent 3587441 commit bfa76a7

File tree

1 file changed

+97
-5
lines changed

1 file changed

+97
-5
lines changed

tests/integration/database/test_database.py

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import time
2+
13
import pytest
24

3-
from tests.integration.helpers import assert_headers_in_lines, exec_test_command
5+
from tests.integration.helpers import assert_headers_in_lines, exec_test_command, delete_target_id
6+
from tests.integration.linodes.helpers_linodes import DEFAULT_LABEL
47

58
BASE_CMD = ["linode-cli", "databases"]
6-
pytestmark = pytest.mark.skip(
7-
"This command is currently only available for customers who already have an active "
8-
"Managed Database."
9-
)
109

1110

1211
def test_engines_list():
@@ -20,6 +19,99 @@ def test_engines_list():
2019
assert_headers_in_lines(headers, lines)
2120

2221

22+
timestamp = str(time.time_ns())
23+
mysql_database_label = DEFAULT_LABEL + "-mysql-" + timestamp
24+
postgresql_database_label = DEFAULT_LABEL + "-postgresql-" + timestamp
25+
26+
27+
@pytest.fixture(scope="package", autouse=True)
28+
def test_mysql_cluster():
29+
database_id = (
30+
exec_test_command(
31+
BASE_CMD
32+
+ [
33+
"mysql-create",
34+
"--type",
35+
"g6-nanode-1",
36+
"--region",
37+
"us-ord",
38+
"--label",
39+
mysql_database_label,
40+
"--engine",
41+
"mysql/8",
42+
"--text",
43+
"--delimiter",
44+
",",
45+
"--no-headers",
46+
"--format",
47+
"id",
48+
"--no-defaults",
49+
"--format",
50+
"id",
51+
]
52+
)
53+
.stdout.decode()
54+
.rstrip()
55+
)
56+
57+
yield database_id
58+
59+
delete_target_id(target="databases", delete_command="mysql-delete", id=database_id)
60+
61+
62+
def test_mysql_suspend_resume(test_mysql_cluster):
63+
database_id = test_mysql_cluster
64+
res = exec_test_command(BASE_CMD + ["mysql-suspend", database_id, "--text", "--delimiter=,"]).stdout.decode()
65+
assert "Request failed: 400" not in res
66+
67+
res = exec_test_command(BASE_CMD + ["mysql-resume", database_id, "--text", "--delimiter=,"]).stdout.decode()
68+
assert "Request failed: 400" not in res
69+
70+
71+
@pytest.fixture(scope="package", autouse=True)
72+
def test_postgresql_cluster():
73+
database_id = (
74+
exec_test_command(
75+
BASE_CMD
76+
+ [
77+
"postgresql-create",
78+
"--type",
79+
"g6-nanode-1",
80+
"--region",
81+
"us-ord",
82+
"--label",
83+
postgresql_database_label,
84+
"--engine",
85+
"postgresql/16",
86+
"--text",
87+
"--delimiter",
88+
",",
89+
"--no-headers",
90+
"--format",
91+
"id",
92+
"--no-defaults",
93+
"--format",
94+
"id",
95+
]
96+
)
97+
.stdout.decode()
98+
.rstrip()
99+
)
100+
101+
yield database_id
102+
103+
delete_target_id(target="databases", delete_command="postgresql-delete", id=database_id)
104+
105+
106+
def test_postgresql_suspend_resume(test_postgresql_cluster):
107+
database_id = test_postgresql_cluster
108+
res = exec_test_command(BASE_CMD + ["postgresql-suspend", database_id, "--text", "--delimiter=,"]).stdout.decode()
109+
assert "Request failed: 400" not in res
110+
111+
res = exec_test_command(BASE_CMD + ["postgresql-resume", database_id, "--text", "--delimiter=,"]).stdout.decode()
112+
assert "Request failed: 400" not in res
113+
114+
23115
@pytest.fixture
24116
def get_engine_id():
25117
engine_id = (

0 commit comments

Comments
 (0)