From 1eca8d48f78872717c196b3eeeace2d363ef89e8 Mon Sep 17 00:00:00 2001 From: Andrea Manzini Date: Tue, 14 Nov 2023 08:38:09 +0100 Subject: [PATCH] Test for firewalld container in ALP product --- schedule/alp/firewalld_container.yaml | 15 ++++++ .../firewalld-container/firewalld_client.pm | 52 +++++++++++++++++++ .../firewalld-container/firewalld_server.pm | 42 +++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 schedule/alp/firewalld_container.yaml create mode 100644 tests/microos/workloads/firewalld-container/firewalld_client.pm create mode 100644 tests/microos/workloads/firewalld-container/firewalld_server.pm diff --git a/schedule/alp/firewalld_container.yaml b/schedule/alp/firewalld_container.yaml new file mode 100644 index 000000000000..22aee0a3d91a --- /dev/null +++ b/schedule/alp/firewalld_container.yaml @@ -0,0 +1,15 @@ +--- +name: Firewalld in a Container +description: > + Install and test firewalld container +conditional_schedule: + firewalld_container: + HOSTNAME: + 'client': + - microos/workloads/firewalld-container/firewalld_client + 'server': + - microos/workloads/firewalld-container/firewalld_server +schedule: + - microos/disk_boot + - network/setup_multimachine.pm + - '{{firewalld_container}}' diff --git a/tests/microos/workloads/firewalld-container/firewalld_client.pm b/tests/microos/workloads/firewalld-container/firewalld_client.pm new file mode 100644 index 000000000000..51ea0f602d38 --- /dev/null +++ b/tests/microos/workloads/firewalld-container/firewalld_client.pm @@ -0,0 +1,52 @@ +# SUSE"s openQA tests +# +# Copyright 2023 SUSE LLC +# SPDX-License-Identifier: FSFAP +# +# Package: podman firewalld-container +# Summary: install and verify firewalld container. +# Maintainer: QE Core + +use base "consoletest"; +use warnings; +use strict; +use testapi; +use serial_terminal 'select_serial_terminal'; +use lockapi; + +sub server_port_is_open { + record_info("CLIENT DEBUG", "test if port is open"); + return 1; +} + +sub server_port_is_closed { + record_info("CLIENT DEBUG", "test if port is closed"); + return 1; +} + + +sub run { + my ($self) = @_; + select_serial_terminal; + record_info("1 client ip a", script_output("ip a")); + #setup MM networking + mutex_wait 'server_ready'; + record_info("2 client ip a", script_output("ip a")); + # server port should be reachable + die unless server_port_is_open(); + mutex_create 'client_test_done'; + mutex_wait 'server_port_closed'; + die unless server_port_is_closed(); + mutex_lock 'client_test_done'; +} + +sub post_fail_hook { + mutex_unlock 'client_test_done'; +} + +sub post_run_hook { + mutex_unlock 'client_test_done'; +} + +1; + diff --git a/tests/microos/workloads/firewalld-container/firewalld_server.pm b/tests/microos/workloads/firewalld-container/firewalld_server.pm new file mode 100644 index 000000000000..cc8bbc7bf105 --- /dev/null +++ b/tests/microos/workloads/firewalld-container/firewalld_server.pm @@ -0,0 +1,42 @@ +# SUSE"s openQA tests +# +# Copyright 2023 SUSE LLC +# SPDX-License-Identifier: FSFAP +# +# Package: podman firewalld-container +# Summary: install and verify firewalld container. +# Maintainer: QE Core + +use base "consoletest"; +use warnings; +use strict; +use testapi; +use serial_terminal 'select_serial_terminal'; +use lockapi; + +sub install_firewalld_container { + record_info("SERVER DEBUG", "installing firewalld container"); +} + +sub close_firewall_port { + record_info("SERVER DEBUG", "closing firewall port"); +} + + +sub run { + my ($self) = @_; + #select_serial_terminal; + select_console 'root-console'; + my $hostname = get_var('HOSTNAME'); + record_info("1 server ip a", script_output("ip a")); + install_firewalld_container(); + mutex_create 'server_ready'; + mutex_wait 'client_test_done'; + close_firewall_port(); + mutex_create 'server_port_closed'; + mutex_wait 'client_test_done'; + record_info("2 server ip a", script_output("ip a")); +} + +1; +