Skip to content

Commit 0ca4876

Browse files
authored
ci: reinforce update-to-next-major-version test (#897)
The new test code are from other update-to-next-version tests. Those tests need rpmrebuild, but looks like it is not supported on EPEL for AlmaLinux 10 yet. So, those tests can not be done for AlmaLinux 10. It would be better to cover those tests on this test as well. Signed-off-by: Daijiro Fukuda <[email protected]>
1 parent f48496f commit 0ca4876

File tree

1 file changed

+79
-8
lines changed

1 file changed

+79
-8
lines changed

fluent-package/yum/systemd-test/update-to-next-major-version.sh

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ status_before_update=$2 # active / inactive
99

1010
install_current
1111

12+
sudo systemctl enable fluentd
13+
1214
if [ "$status_before_update" = active ]; then
1315
sudo systemctl start fluentd
16+
main_pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
1417
fi
1518

1619
# Set FLUENT_PACKAGE_SERVICE_RESTART
@@ -30,13 +33,81 @@ sudo $DNF install -y $package
3033
# Show bundled ruby version
3134
/opt/fluent/bin/ruby -v
3235

33-
# Test: Check whether plugin/gem were installed during upgrading
34-
if [ "$service_restart" != manual ] && [ "$status_before_update" = active ]; then
35-
# plugin gem should be installed automatically
36-
/opt/fluent/bin/fluent-gem list | grep fluent-plugin-concat
37-
# Non fluent-plugin- prefix gem should not be installed automatically
38-
(! /opt/fluent/bin/fluent-gem list | grep gqtp)
39-
else
40-
# plugin gem should not be installed automatically
36+
# Test: The service should take over the state
37+
systemctl is-enabled fluentd
38+
39+
if [ "$status_before_update" = inactive ]; then
40+
# Test: The service should NOT start automatically
41+
(! systemctl is-active fluentd)
42+
# Test: Plugin gem should not be installed automatically
4143
(! /opt/fluent/bin/fluent-gem list | grep fluent-plugin-concat)
44+
else
45+
# Test: The process before update should continue to run
46+
systemctl is-active fluentd
47+
test $main_pid -eq $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
48+
49+
sleep 15
50+
51+
if [ "$service_restart" = manual ]; then
52+
# Test: Plugin gem should not be installed automatically
53+
(! /opt/fluent/bin/fluent-gem list | grep fluent-plugin-concat)
54+
# Test: Main process should NOT be replaced until USR2 signal fired
55+
test $main_pid -eq $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
56+
57+
sudo kill -USR2 $main_pid
58+
sleep 15
59+
60+
# Test: Main process should be replaced by USR2 signal
61+
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
62+
else
63+
# Test: Plugin gem should be installed automatically
64+
/opt/fluent/bin/fluent-gem list | grep fluent-plugin-concat
65+
# Test: Non fluent-plugin- prefix gem should not be installed automatically
66+
(! /opt/fluent/bin/fluent-gem list | grep gqtp)
67+
# Test: Main process should be replaced automatically
68+
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
69+
fi
4270
fi
71+
72+
# Ensure the service is started
73+
sudo systemctl start fluentd
74+
75+
# Test: migration process from v4 must not be done
76+
(! test -e /etc/td-agent)
77+
(! test -e /etc/fluent/td-agent.conf)
78+
(! test -e /var/log/td-agent)
79+
(! test -e /var/log/fluent/td-agent.log)
80+
(! test -h /usr/sbin/td-agent)
81+
(! test -h /usr/sbin/td-agent-gem)
82+
83+
# Test: environmental variables
84+
pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
85+
env_vars=$(sudo sed -e 's/\x0/\n/g' /proc/$pid/environ)
86+
test $(eval $env_vars && echo $HOME) = "/var/lib/fluent"
87+
test $(eval $env_vars && echo $LOGNAME) = "fluentd"
88+
test $(eval $env_vars && echo $USER) = "fluentd"
89+
test $(eval $env_vars && echo $FLUENT_CONF) = "/etc/fluent/fluentd.conf"
90+
test $(eval $env_vars && echo $FLUENT_PACKAGE_LOG_FILE) = "/var/log/fluent/fluentd.log"
91+
test $(eval $env_vars && echo $FLUENT_PLUGIN) = "/etc/fluent/plugin"
92+
test $(eval $env_vars && echo $FLUENT_SOCKET) = "/var/run/fluent/fluentd.sock"
93+
94+
# Test: logs
95+
sleep 3
96+
test -e /var/log/fluent/fluentd.log
97+
(! grep -e '\[warn\]' -e '\[error\]' -e '\[fatal\]' /var/log/fluent/fluentd.log)
98+
99+
# Uninstall
100+
sudo $DNF remove -y fluent-package
101+
sudo systemctl daemon-reload
102+
103+
(! getent passwd td-agent >/dev/null)
104+
(! getent group td-agent >/dev/null)
105+
getent passwd fluentd >/dev/null
106+
getent group fluentd >/dev/null
107+
108+
# `sudo systemctl daemon-reload` clears the service completely.
109+
# (The result of `systemctl status` will be `unfound`)
110+
# Note: RPM does not leave links like `@/etc/systemd/system/fluentd.service`.
111+
# (Different from deb)
112+
113+
(! systemctl status --no-pager fluentd)

0 commit comments

Comments
 (0)