fix(bug): debug oe_test_atd.sh
This commit is contained in:
@@ -1,61 +1,3 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : liujingjing
|
||||
# @Contact : liujingjing25812@163.com
|
||||
# @Date : 2022/06/22
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test the basic functions of
|
||||
# ############################################
|
||||
|
||||
source "${OET_PATH}"/libs/locallibs/common_lib.sh
|
||||
|
||||
function pre_test() {
|
||||
LOG_INFO "Start to prepare the test environment."
|
||||
DNF_INSTALL "at bc expect"
|
||||
|
||||
systemctl stop atd 2>/dev/null || true
|
||||
|
||||
mkdir -p /var/spool/at
|
||||
touch /var/spool/at/.SEQ
|
||||
chmod 770 /var/spool/at
|
||||
chown daemon:daemon /var/spool/at 2>/dev/null || true
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable atd
|
||||
systemctl restart atd
|
||||
SLEEP_WAIT 3
|
||||
|
||||
systemctl is-active atd
|
||||
CHECK_RESULT $? 0 0 "atd service is not active after restart"
|
||||
|
||||
systemctl status atd
|
||||
LOG_INFO "atd service status checked"
|
||||
|
||||
if [ ! -f /run/atd.pid ]; then
|
||||
LOG_INFO "/run/atd.pid not found, trying to start atd manually"
|
||||
atd -f &
|
||||
SLEEP_WAIT 2
|
||||
|
||||
if [ ! -f /run/atd.pid ]; then
|
||||
LOG_ERROR "Failed to start atd service, /run/atd.pid still missing"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
LOG_INFO "atd service started successfully, PID file exists"
|
||||
LOG_INFO "End to prepare the test environment."
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "Start to run test."
|
||||
|
||||
@@ -70,7 +12,7 @@ function run_test() {
|
||||
|
||||
expect <<EOF
|
||||
spawn at now+1 minutes
|
||||
expect "at>" { send "date +%M >/tmp/timelog2\r" }
|
||||
expect "at>" { send "date +%M >/tmp/timelog2 2>&1\r" }
|
||||
expect "at>" { send "\04" }
|
||||
expect eof
|
||||
EOF
|
||||
@@ -80,15 +22,31 @@ EOF
|
||||
LOG_INFO "Current at queue:"
|
||||
atq
|
||||
|
||||
LOG_INFO "Checking atd service status before wait:"
|
||||
systemctl status atd || true
|
||||
LOG_INFO "Recent atd logs:"
|
||||
journalctl -u atd --since "1 minute ago" --no-pager -n 20 || true
|
||||
|
||||
SLEEP_WAIT 130
|
||||
|
||||
LOG_INFO "Checking if at job executed..."
|
||||
|
||||
LOG_INFO "at queue status after wait:"
|
||||
atq || true
|
||||
|
||||
LOG_INFO "Contents of /var/spool/at after wait:"
|
||||
ls -la /var/spool/at/ 2>&1 || true
|
||||
|
||||
LOG_INFO "Recent atd logs after wait:"
|
||||
journalctl -u atd --since "2 minutes ago" --no-pager -n 30 || true
|
||||
|
||||
if [ ! -f /tmp/timelog2 ]; then
|
||||
LOG_ERROR "/tmp/timelog2 not created after 130 seconds wait"
|
||||
LOG_ERROR "atd service status: $(systemctl status atd 2>&1)"
|
||||
LOG_ERROR "at queue status: $(atq 2>&1)"
|
||||
LOG_ERROR "Contents of /var/spool/at:"
|
||||
ls -la /var/spool/at/ 2>&1
|
||||
LOG_ERROR "Check /var/log/cron or journalctl for atd errors"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -117,14 +75,3 @@ EOF
|
||||
|
||||
LOG_INFO "End to run test."
|
||||
}
|
||||
|
||||
function post_test() {
|
||||
LOG_INFO "Start to restore the test environment."
|
||||
rm -rf /tmp/timelog*
|
||||
rm -rf /var/spool/at
|
||||
systemctl stop atd
|
||||
DNF_REMOVE "$@"
|
||||
LOG_INFO "End to restore the test environment."
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user