Skip to content

Commit

Permalink
Test placement (linode#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
vshanthe authored Aug 30, 2024
1 parent ba4addd commit 5e6003b
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def support_test_linode_id(linode_cloud_firewall):
"--type",
"g6-nanode-1",
"--region",
"us-ord",
"us-mia",
"--image",
DEFAULT_TEST_IMAGE,
"--label",
Expand Down
136 changes: 136 additions & 0 deletions tests/integration/placements/test_placements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import time

import pytest

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

BASE_CMD = ["linode-cli", "placement"]


@pytest.fixture
def create_placement_group():
new_label = str(time.time_ns()) + "label"
placement_group_id = (
exec_test_command(
BASE_CMD
+ [
"group-create",
"--label",
new_label,
"--region",
"us-mia",
"--placement_group_type",
"anti_affinity:local",
"--placement_group_policy",
"strict",
"--text",
"--no-headers",
"--format=id",
]
)
.stdout.decode()
.rstrip()
)
yield placement_group_id
delete_target_id(
target="placement", subcommand="group-delete", id=placement_group_id
)


def test_placement_group_list():
res = (
exec_test_command(BASE_CMD + ["groups-list", "--text", "--delimiter=,"])
.stdout.decode()
.rstrip()
)
lines = res.splitlines()
headers = ["placement_group_type", "region", "label"]
assert_headers_in_lines(headers, lines)


def test_placement_group_view(create_placement_group):
placement_group_id = create_placement_group
res = (
exec_test_command(
BASE_CMD
+ ["group-view", placement_group_id, "--text", "--delimiter=,"]
)
.stdout.decode()
.rstrip()
)
lines = res.splitlines()

headers = ["placement_group_type", "region", "label"]
assert_headers_in_lines(headers, lines)


@pytest.mark.skip(reason="BUG TPT-3109")
def test_assign_placement_group(support_test_linode_id, create_placement_group):
linode_id = support_test_linode_id
placement_group_id = create_placement_group
res = (
exec_test_command(
BASE_CMD
+ [
"assign-linode",
placement_group_id,
"--linodes",
linode_id,
"--text",
"--delimiter=,",
]
)
.stdout.decode()
.rstrip()
)
assert placement_group_id in res


@pytest.mark.skip(reason="BUG TPT-3109")
def test_unassign_placement_group(
support_test_linode_id, create_placement_group
):
linode_id = support_test_linode_id
placement_group_id = create_placement_group
res = (
exec_test_command(
BASE_CMD
+ [
"unassign-linode",
placement_group_id,
"--linode",
linode_id,
"--text",
"--delimiter=,",
]
)
.stdout.decode()
.rstrip()
)
assert placement_group_id not in res


def test_update_placement_group(create_placement_group):
placement_group_id = create_placement_group
new_label = str(time.time_ns()) + "label"
updated_label = (
exec_test_command(
BASE_CMD
+ [
"group-update",
placement_group_id,
"--label",
new_label,
"--text",
"--no-headers",
"--format=label",
]
)
.stdout.decode()
.rstrip()
)
assert new_label == updated_label

0 comments on commit 5e6003b

Please sign in to comment.