This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
External Volumes Integration Tests for Hello-World and Cassandra. (#3322
) SDK: * Add improved logging to indicate Pod-Replacement policy has been used. Hello-World: * Add scenario with external-volumes and basic integration test. Cassandra: * Add flag to enable/disable Pod-Replacement failure policy. * Remove mentions of Portworx from service spec, switch NetApp to Generic Driver. * Add basic integration test.
- Loading branch information
1 parent
c53d4fe
commit 6982478
Showing
18 changed files
with
476 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
from typing import Iterator | ||
|
||
import pytest | ||
import sdk_external_volumes | ||
import sdk_security | ||
from tests import config | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def configure_security(configure_universe: None) -> Iterator[None]: | ||
yield from sdk_security.security_session(config.SERVICE_NAME) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def configure_external_volumes(): | ||
# Handle creation of external volumes. | ||
yield from sdk_external_volumes.external_volumes_session() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import logging | ||
import pytest | ||
import re | ||
|
||
import sdk_agents | ||
import sdk_install | ||
import sdk_plan | ||
import sdk_tasks | ||
from tests import config | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def configure_package(configure_security): | ||
try: | ||
sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) | ||
yield # let the test session execute | ||
finally: | ||
sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) | ||
|
||
|
||
@pytest.mark.external_volumes | ||
@pytest.mark.sanity | ||
@pytest.mark.dcos_min_version("2.1") | ||
def test_default_deployment(): | ||
# Test default installation with external volumes. | ||
# Ensure service comes up successfully. | ||
options = { | ||
"nodes": {"external_volume": {"enabled": True}}, | ||
} | ||
sdk_install.install( | ||
config.PACKAGE_NAME, | ||
config.SERVICE_NAME, | ||
3, | ||
additional_options=options, | ||
wait_for_deployment=True, | ||
) | ||
# Wait for scheduler to restart. | ||
sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME) | ||
|
||
|
||
@pytest.mark.skip(reason="Conflicts with Cassandra Custom Recovery Manager") | ||
@pytest.mark.sanity | ||
def test_auto_replace_on_drain(): | ||
candidate_tasks = sdk_tasks.get_tasks_avoiding_scheduler( | ||
config.SERVICE_NAME, re.compile("^node-[0-9]+-server$") | ||
) | ||
|
||
assert len(candidate_tasks) != 0, "Could not find a node to drain" | ||
|
||
# Pick the host of the first task from the above list | ||
replace_agent_id = candidate_tasks[0].agent_id | ||
replace_tasks = [task for task in candidate_tasks if task.agent_id == replace_agent_id] | ||
log.info( | ||
"Tasks on agent {} to be replaced after drain: {}".format(replace_agent_id, replace_tasks) | ||
) | ||
sdk_agents.drain_agent(replace_agent_id) | ||
|
||
sdk_plan.wait_for_kicked_off_recovery(config.SERVICE_NAME) | ||
sdk_plan.wait_for_completed_recovery(config.SERVICE_NAME) | ||
|
||
new_tasks = sdk_tasks.get_summary() | ||
|
||
for replaced_task in replace_tasks: | ||
new_task = [ | ||
task | ||
for task in new_tasks | ||
if task.name == replaced_task.name and task.id != replaced_task.id | ||
][0] | ||
log.info( | ||
"Checking affected task has moved to a new agent:\n" | ||
"old={}\nnew={}".format(replaced_task, new_task) | ||
) | ||
assert replaced_task.agent_id != new_task.agent_id | ||
|
||
# Reactivate the drained agent, otherwise uninstall plans will be halted for portworx | ||
sdk_agents.reactivate_agent(replace_agent_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: {{FRAMEWORK_NAME}} | ||
scheduler: | ||
principal: {{FRAMEWORK_PRINCIPAL}} | ||
user: {{FRAMEWORK_USER}} | ||
pods: | ||
hello: | ||
count: {{HELLO_COUNT}} | ||
placement: '{{{HELLO_PLACEMENT}}}' | ||
external-volumes: | ||
hello-volume: | ||
type: DOCKER | ||
volume-mode: RW | ||
container-path: hello-container-path | ||
driver-name: {{EXTERNAL_VOLUME_DRIVER_NAME}} | ||
driver-options: {{EXTERNAL_VOLUME_DRIVER_OPTIONS}} | ||
{{#HELLO_EXTERNAL_VOLUME_NAME}} | ||
volume-name: {{HELLO_EXTERNAL_VOLUME_NAME}} | ||
{{/HELLO_EXTERNAL_VOLUME_NAME}} | ||
tasks: | ||
server: | ||
goal: RUNNING | ||
cmd: env && echo hello >> hello-container-path/output && sleep $SLEEP_DURATION | ||
cpus: {{HELLO_CPUS}} | ||
memory: {{HELLO_MEM}} | ||
env: | ||
SLEEP_DURATION: {{SLEEP_DURATION}} | ||
health-check: | ||
cmd: stat hello-container-path/output | ||
interval: 5 | ||
grace-period: 30 | ||
delay: 0 | ||
timeout: 10 | ||
max-consecutive-failures: 3 | ||
labels: {{HELLO_LABELS}} | ||
world: | ||
count: {{WORLD_COUNT}} | ||
allow-decommission: true | ||
placement: '{{{WORLD_PLACEMENT}}}' | ||
external-volumes: | ||
world-volume: | ||
type: DOCKER | ||
volume-mode: RW | ||
container-path: world-container-path | ||
driver-name: {{EXTERNAL_VOLUME_DRIVER_NAME}} | ||
driver-options: {{EXTERNAL_VOLUME_DRIVER_OPTIONS}} | ||
{{#WORLD_EXTERNAL_VOLUME_NAME}} | ||
volume-name: {{WORLD_EXTERNAL_VOLUME_NAME}} | ||
{{/WORLD_EXTERNAL_VOLUME_NAME}} | ||
tasks: | ||
server: | ||
goal: RUNNING | ||
cmd: | | ||
# for graceful shutdown | ||
# trap SIGTERM and mock a cleanup timeframe | ||
terminated () { | ||
echo "$(date) received SIGTERM, zzz for 3 ..." | ||
sleep 3 | ||
echo "$(date) ... all clean, peace out" | ||
exit 0 | ||
} | ||
trap terminated SIGTERM | ||
echo "$(date) trapping SIGTERM, watch here for the signal..." | ||
echo "${TASK_NAME}" >>world-container-path/output && | ||
# instead of running for a short duration (equal to SLEEP_DURATION), run infinitely | ||
# to allow for testing of SIGTERM..grace..SIGKILL | ||
while true; do | ||
sleep 0.1 | ||
done | ||
cpus: {{WORLD_CPUS}} | ||
memory: {{WORLD_MEM}} | ||
env: | ||
SLEEP_DURATION: {{SLEEP_DURATION}} | ||
readiness-check: | ||
# wordcount (wc) will report an error if the file does not exist, which effectively is zero (0) bytes | ||
# so send the error to /dev/null, BUT also zero-left-pad the variable BYTES to ensure that it is zero | ||
# on empty for comparison sake. | ||
cmd: BYTES="$(wc -c world-container-path/output 2>/dev/null| awk '{print $1;}')" && [ 0$BYTES -gt 0 ] | ||
interval: {{WORLD_READINESS_CHECK_INTERVAL}} | ||
delay: {{WORLD_READINESS_CHECK_DELAY}} | ||
timeout: {{WORLD_READINESS_CHECK_TIMEOUT}} | ||
kill-grace-period: {{WORLD_KILL_GRACE_PERIOD}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.