-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from O1ahmad/ahmad/add_container_uninstall_tests
chore: add initial container uninstall scenario tests
- Loading branch information
Showing
8 changed files
with
140 additions
and
15 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
Empty file.
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,75 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
roles: | ||
- role: basic-service | ||
vars: | ||
uninstall: false | ||
setup_mode: container | ||
name: full-container | ||
image: prom/prometheus:latest | ||
user: root | ||
command: --config.file=/etc/prometheus/prometheus.yml | ||
cpus: 2 | ||
memory: 1024M | ||
network_mode: bridge | ||
ports: | ||
prometheus: | ||
ingressPort: 9090 | ||
servicePort: 9090 | ||
host_data_dir: /test/mnt/prometheus | ||
config: | ||
prometheus-config: | ||
destinationPath: /etc/prometheus/prometheus.yml | ||
data: | | ||
global: | ||
scrape_interval: 15s | ||
evaluation_interval: 15s | ||
scrape_configs: | ||
- job_name: 'prometheus' | ||
static_configs: | ||
- targets: ['localhost:9090'] | ||
config_env: | ||
PROMETHEUS_STORAGE_PATH: "/prometheus" | ||
data_dirs: | ||
prometheus-data: | ||
hostPath: /tmp/prometheus | ||
appPath: /prometheus | ||
restart_policy: always | ||
- role: basic-service | ||
vars: | ||
uninstall: true | ||
setup_mode: container | ||
name: full-container | ||
image: prom/prometheus:latest | ||
user: root | ||
command: --config.file=/etc/prometheus/prometheus.yml | ||
cpus: 2 | ||
memory: 1024M | ||
network_mode: bridge | ||
ports: | ||
prometheus: | ||
ingressPort: 9090 | ||
servicePort: 9090 | ||
host_data_dir: /test/mnt/prometheus | ||
config: | ||
prometheus-config: | ||
destinationPath: /etc/prometheus/prometheus.yml | ||
data: | | ||
global: | ||
scrape_interval: 15s | ||
evaluation_interval: 15s | ||
scrape_configs: | ||
- job_name: 'prometheus' | ||
static_configs: | ||
- targets: ['localhost:9090'] | ||
config_env: | ||
PROMETHEUS_STORAGE_PATH: "/prometheus" | ||
data_dirs: | ||
prometheus-data: | ||
hostPath: /tmp/prometheus | ||
appPath: /prometheus | ||
restart_policy: always |
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,31 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: docker:24.0.5-dind | ||
privileged: true | ||
network_mode: host | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- /test/mnt:/test/mnt | ||
provisioner: | ||
name: ansible | ||
playbooks: | ||
prepare: ../prepare-docker.yml | ||
env: | ||
ANSIBLE_ROLES_PATH: "../../../../" | ||
verifier: | ||
name: testinfra | ||
directory: ./tests | ||
scenario: | ||
name: container-uninstall | ||
test_sequence: | ||
- dependency | ||
- create | ||
- prepare | ||
- converge | ||
- verify | ||
- destroy |
19 changes: 19 additions & 0 deletions
19
tests/molecule/container-uninstall/tests/test_container_uninstall.py
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,19 @@ | ||
def test_container_removed(host): | ||
"""Verify the container has been removed.""" | ||
container = host.run("docker ps -a --filter 'name=full-container' --format '{{.Names}}'") | ||
assert container.stdout.strip() == "", "The container 'full-container' still exists." | ||
|
||
def test_config_directory_removed(host): | ||
"""Verify the configuration directory has been removed.""" | ||
config_dir = host.file("/test/mnt/etc/prometheus") | ||
assert not config_dir.exists, "The configuration directory still exists." | ||
|
||
def test_data_directory_removed(host): | ||
"""Verify the data directory has been removed.""" | ||
data_dir = host.file("/tmp/prometheus") | ||
assert not data_dir.exists, "The data directory still exists." | ||
|
||
def test_host_data_directory_removed(host): | ||
"""Verify the host data directory has been removed.""" | ||
host_data_dir = host.file("/test/mnt/prometheus") | ||
assert not host_data_dir.exists, "The host data directory still exists." |