[Fuego] [PATCH] dovecot:Use get_service_status to restore the status of service after the test is over.
Tim.Bird at sony.com
Tim.Bird at sony.com
Wed Apr 17 05:14:33 UTC 2019
Looks good. Applied to the fuegotest 'next' branch.
Thanks!
-- Tim
> -----Original Message-----
> From: Wang Mingyu
> Sent: Friday, March 15, 2019 6:56 AM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH] dovecot:Use get_service_status to restore the
> status of service after the test is over.
>
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
> tests/Functional.dovecot/dovecot_test.sh | 5 ++-
> tests/Functional.dovecot/fuego_test.sh | 5 +--
> tests/Functional.dovecot/spec.json | 1 -
> tests/Functional.dovecot/tests/dovecot_listen.sh | 9 +++--
> tests/Functional.dovecot/tests/dovecot_logfile.sh | 45
> +++++++++++++++++++----
> tests/Functional.dovecot/tests/dovecot_pidfile.sh | 13 +++++--
> tests/Functional.dovecot/tests/dovecot_ps.sh | 17 ++++++---
> 7 files changed, 68 insertions(+), 27 deletions(-)
> mode change 100644 => 100755 tests/Functional.dovecot/dovecot_test.sh
>
> diff --git a/tests/Functional.dovecot/dovecot_test.sh
> b/tests/Functional.dovecot/dovecot_test.sh
> old mode 100644
> new mode 100755
> index dd5ce37..95c34db
> --- a/tests/Functional.dovecot/dovecot_test.sh
> +++ b/tests/Functional.dovecot/dovecot_test.sh
> @@ -1,4 +1,7 @@
> #!/bin/sh
> +. ./fuego_board_function_lib.sh
> +set_init_manager
> +
> for i in tests/*.sh; do
> - sh $i
> + source $i
> done
> diff --git a/tests/Functional.dovecot/fuego_test.sh
> b/tests/Functional.dovecot/fuego_test.sh
> index f86510a..92fbe69 100644
> --- a/tests/Functional.dovecot/fuego_test.sh
> +++ b/tests/Functional.dovecot/fuego_test.sh
> @@ -1,6 +1,5 @@
> function test_pre_check {
> - is_on_target_path dovecot PROGRAM_DOVECOT
> - assert_define PROGRAM_DOVECOT "Missing 'dovecot' program on target
> board"
> + assert_has_program dovecot
> }
>
> function test_deploy {
> @@ -11,7 +10,7 @@ function test_deploy {
>
> function test_run {
> report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> - sh -v dovecot_test.sh"
> + ./dovecot_test.sh"
> }
>
> function test_processing {
> diff --git a/tests/Functional.dovecot/spec.json
> b/tests/Functional.dovecot/spec.json
> index 3a71a30..c1acde1 100644
> --- a/tests/Functional.dovecot/spec.json
> +++ b/tests/Functional.dovecot/spec.json
> @@ -4,4 +4,3 @@
> "default": {}
> }
> }
> -
> diff --git a/tests/Functional.dovecot/tests/dovecot_listen.sh
> b/tests/Functional.dovecot/tests/dovecot_listen.sh
> index 7471d79..26f4381 100644
> --- a/tests/Functional.dovecot/tests/dovecot_listen.sh
> +++ b/tests/Functional.dovecot/tests/dovecot_listen.sh
> @@ -5,9 +5,7 @@
>
> test="listen"
>
> -. "./fuego_board_function_lib.sh"
> -
> -set_init_manager
> +service_status=$(get_service_status dovecot)
>
> exec_service_on_target dovecot stop
>
> @@ -26,4 +24,7 @@ else
> echo " -> $test: TEST-FAIL"
> fi
>
> -exec_service_on_target dovecot stop
> +if [ "$service_status" = "inactive" ]
> +then
> + exec_service_on_target dovecot stop
> +fi
> diff --git a/tests/Functional.dovecot/tests/dovecot_logfile.sh
> b/tests/Functional.dovecot/tests/dovecot_logfile.sh
> index 7489103..fed6067 100644
> --- a/tests/Functional.dovecot/tests/dovecot_logfile.sh
> +++ b/tests/Functional.dovecot/tests/dovecot_logfile.sh
> @@ -3,18 +3,37 @@
> # In the target to start dovecot dovecot, to confirm the acquisition of the
> log.
> # check the keyword "dovecot".
>
> -
> test="logfile"
> -service_name=""
> -
> -. "./fuego_board_function_lib.sh"
>
> -set_init_manager
> +service_status=$(get_service_status dovecot)
> +logger_service=$(detect_logger_service)
>
> exec_service_on_target dovecot stop
> -rm -f /var/log/mail.log
>
> -exec_service_on_target $service_name restart
> +if [ -f /var/log/mail.log ]
> +then
> + mv /var/log/mail.log /var/log/mail.log_bak
> +fi
> +
> +if [ -f /var/log/messages ]
> +then
> + mv /var/log/messages /var/log/messages_bak
> +fi
> +
> +restore_target() {
> + if [ -f /var/log/messages_bak ]
> + then
> + mv /var/log/messages_bak /var/log/messages
> + fi
> + if [ -f /var/log/mail.log_bak ]
> + then
> + mv /var/log/mail.log_bak /var/log/mail.log
> + fi
> +}
> +
> +exec_service_on_target $logger_service restart
> +
> +sleep 3
>
> if exec_service_on_target dovecot start
> then
> @@ -22,13 +41,23 @@ then
> else
> echo " -> start of dovecot failed."
> echo " -> $test: TEST-FAIL"
> + restore_target
> + exit
> fi
>
> +sleep 3
> +
> if tail /var/log/mail.log | grep "dovecot"
> then
> - echo " -> $test: TEST-PASS"
> + echo " -> grep dovecto from mail.log"
> else
> + echo " -> can't grep dovecto from mail.log"
> echo " -> $test: TEST-FAIL"
> fi
>
> exec_service_on_target dovecot stop
> +restore_target
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target dovecot start
> +fi
> diff --git a/tests/Functional.dovecot/tests/dovecot_pidfile.sh
> b/tests/Functional.dovecot/tests/dovecot_pidfile.sh
> index 95df023..06f4a2a 100644
> --- a/tests/Functional.dovecot/tests/dovecot_pidfile.sh
> +++ b/tests/Functional.dovecot/tests/dovecot_pidfile.sh
> @@ -5,9 +5,7 @@
>
> test="pidfile"
>
> -. "./fuego_board_function_lib.sh"
> -
> -set_init_manager
> +service_status=$(get_service_status dovecot)
>
> exec_service_on_target dovecot stop
>
> @@ -27,7 +25,10 @@ then
> else
> echo " -> ls /var/run/dovecot/master.pid failed."
> echo " -> $test: TEST-FAIL"
> - exec_service_on_target dovecot stop
> + if [ "$service_status" = "inactive" ]
> + then
> + exec_service_on_target dovecot stop
> + fi
> exit
> fi
>
> @@ -39,3 +40,7 @@ then
> else
> echo " -> $test: TEST-FAIL"
> fi
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target dovecot start
> +fi
> diff --git a/tests/Functional.dovecot/tests/dovecot_ps.sh
> b/tests/Functional.dovecot/tests/dovecot_ps.sh
> index 2c627bb..190b14d 100644
> --- a/tests/Functional.dovecot/tests/dovecot_ps.sh
> +++ b/tests/Functional.dovecot/tests/dovecot_ps.sh
> @@ -5,9 +5,7 @@
>
> test="ps"
>
> -. "./fuego_board_function_lib.sh"
> -
> -set_init_manager
> +service_status=$(get_service_status dovecot)
>
> exec_service_on_target dovecot stop
> if exec_service_on_target dovecot start
> @@ -19,13 +17,16 @@ else
> exit
> fi
>
> -if ps -N a | grep [d]ovecot
> +if ps -N a | grep "[/]usr/sbin/dovecot"
> then
> echo " -> get the pid of dovecot."
> else
> echo " -> can't get the pid of dovecot."
> echo " -> $test: TEST-FAIL"
> - exec_service_on_target dovecot stop
> + if [ "$service_status" = "inactive" ]
> + then
> + exec_service_on_target dovecot stop
> + fi
> exit
> fi
>
> @@ -38,9 +39,13 @@ else
> exit
> fi
>
> -if ps -N a | grep [d]ovecot
> +if ps -N a | grep "[/]usr/sbin/dovecot"
> then
> echo " -> $test: TEST-FAIL"
> else
> echo " -> $test: TEST-PASS"
> fi
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target dovecot start
> +fi
> --
> 1.8.3.1
>
>
>
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
More information about the Fuego
mailing list