Skip to content

Commit 0ed9d73

Browse files
Added integration tests for suspend and resume (#743)
1 parent e0d17e3 commit 0ed9d73

File tree

1 file changed

+114
-5
lines changed

1 file changed

+114
-5
lines changed

tests/integration/database/test_database.py

+114-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
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 (
6+
assert_headers_in_lines,
7+
delete_target_id,
8+
exec_test_command,
9+
)
10+
from tests.integration.linodes.helpers_linodes import DEFAULT_LABEL
411

512
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-
)
1013

1114

1215
def test_engines_list():
@@ -20,6 +23,112 @@ def test_engines_list():
2023
assert_headers_in_lines(headers, lines)
2124

2225

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

0 commit comments

Comments
 (0)