Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 114 additions & 5 deletions tests/integration/database/test_database.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import time

import pytest

from tests.integration.helpers import assert_headers_in_lines, exec_test_command
from tests.integration.helpers import (
assert_headers_in_lines,
delete_target_id,
exec_test_command,
)
from tests.integration.linodes.helpers_linodes import DEFAULT_LABEL

BASE_CMD = ["linode-cli", "databases"]
pytestmark = pytest.mark.skip(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

"This command is currently only available for customers who already have an active "
"Managed Database."
)


def test_engines_list():
Expand All @@ -20,6 +23,112 @@ def test_engines_list():
assert_headers_in_lines(headers, lines)


timestamp = str(time.time_ns())
mysql_database_label = DEFAULT_LABEL + "-mysql-" + timestamp
postgresql_database_label = DEFAULT_LABEL + "-postgresql-" + timestamp


@pytest.fixture(scope="package", autouse=True)
def test_mysql_cluster():
database_id = (
exec_test_command(
BASE_CMD
+ [
"mysql-create",
"--type",
"g6-nanode-1",
"--region",
"us-ord",
"--label",
mysql_database_label,
"--engine",
"mysql/8",
"--text",
"--delimiter",
",",
"--no-headers",
"--format",
"id",
"--no-defaults",
"--format",
"id",
]
)
.stdout.decode()
.rstrip()
)

yield database_id

delete_target_id(
target="databases", delete_command="mysql-delete", id=database_id
)


def test_mysql_suspend_resume(test_mysql_cluster):
database_id = test_mysql_cluster
res = exec_test_command(
BASE_CMD + ["mysql-suspend", database_id, "--text", "--delimiter=,"]
).stdout.decode()
assert "Request failed: 400" not in res

res = exec_test_command(
BASE_CMD + ["mysql-resume", database_id, "--text", "--delimiter=,"]
).stdout.decode()
assert "Request failed: 400" not in res


@pytest.fixture(scope="package", autouse=True)
def test_postgresql_cluster():
database_id = (
exec_test_command(
BASE_CMD
+ [
"postgresql-create",
"--type",
"g6-nanode-1",
"--region",
"us-ord",
"--label",
postgresql_database_label,
"--engine",
"postgresql/16",
"--text",
"--delimiter",
",",
"--no-headers",
"--format",
"id",
"--no-defaults",
"--format",
"id",
]
)
.stdout.decode()
.rstrip()
)

yield database_id

delete_target_id(
target="databases", delete_command="postgresql-delete", id=database_id
)


def test_postgresql_suspend_resume(test_postgresql_cluster):
database_id = test_postgresql_cluster
res = exec_test_command(
BASE_CMD
+ ["postgresql-suspend", database_id, "--text", "--delimiter=,"]
).stdout.decode()
assert "Request failed: 400" not in res

res = exec_test_command(
BASE_CMD + ["postgresql-resume", database_id, "--text", "--delimiter=,"]
).stdout.decode()
assert "Request failed: 400" not in res


@pytest.fixture
def get_engine_id():
engine_id = (
Expand Down