Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system-test: add update test from v5 LTS and downgrade test to v5 LTS #761

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ jobs:
- "update-from-v4.sh local"
- "update-from-v4.sh v5"
- "update-from-v4.sh lts"
- "update-from-v5-lts.sh"
- "downgrade-to-v4.sh"
- "downgrade-to-v5-lts.sh"
- "install-newly.sh local"
- "install-newly.sh v5"
- "install-newly.sh lts"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ jobs:
- AmazonLinux 2023 x86_64
test:
- "update-from-v4.sh"
- "update-from-v5-lts.sh"
- "downgrade-to-v4.sh"
- "downgrade-to-v5-lts.sh"
- "install-newly.sh local"
- "install-newly.sh v5"
- "install-newly.sh lts"
Expand Down Expand Up @@ -214,7 +216,9 @@ jobs:
- AlmaLinux 9 x86_64
test:
- "update-from-v4.sh"
- "update-from-v5-lts.sh"
- "downgrade-to-v4.sh"
- "downgrade-to-v5-lts.sh"
- "install-newly.sh local"
- "install-newly.sh v5"
- "install-newly.sh lts"
Expand Down
2 changes: 2 additions & 0 deletions fluent-package/apt/commonvar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ architecture=$(dpkg --print-architecture)
repositories_dir=/fluentd/fluent-package/apt/repositories
java_jdk=openjdk-11-jre
td_agent_version=4.5.2
fluent_package_lts_version=5.0.5

case ${code_name} in
xenial)
distribution=ubuntu
Expand Down
28 changes: 28 additions & 0 deletions fluent-package/apt/systemd-test/downgrade-to-v5-lts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -exu

. $(dirname $0)/../commonvar.sh

# Install v5 LTS to register the repository
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5-lts.sh | sh

sudo apt purge -y fluent-package

# Install the current
sudo apt install -V -y \
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb

# Test: service status
systemctl status --no-pager fluentd
systemctl status --no-pager td-agent
main_pid=$(eval $(systemctl show td-agent --property=MainPID) && echo $MainPID)

# Downgrade to v5 LTS
apt install -V -y fluent-package=${fluent_package_lts_version}-1 --allow-downgrades

systemctl status --no-pager fluentd
systemctl status --no-pager td-agent

# Fluentd should be restarted.
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
69 changes: 69 additions & 0 deletions fluent-package/apt/systemd-test/update-from-v5-lts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

set -exu

. $(dirname $0)/../commonvar.sh


# If it update from v5 LTS without stopping Fluentd, Fluentd will not be restarted.
# Install v5 LTS
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5-lts.sh | sh

systemctl status --no-pager fluentd
systemctl status --no-pager td-agent
main_pid=$(eval $(systemctl show td-agent --property=MainPID) && echo $MainPID)

# Install the current
sudo apt install -V -y \
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb

# Test: service status
systemctl status --no-pager fluentd
systemctl status --no-pager td-agent

# Fluentd should NOT be restarted.
test $main_pid -eq $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)

apt purge -y fluent-package

# If it update from v5 LTS with stopping Fluentd, Fluentd will be started when service is enabled.
# Install v5 LTS
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5-lts.sh | sh

systemctl status --no-pager fluentd
systemctl status --no-pager td-agent
main_pid=$(eval $(systemctl show td-agent --property=MainPID) && echo $MainPID)

systemctl stop fluentd

# Install the current
sudo apt install -V -y \
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb

systemctl status --no-pager fluentd
systemctl status --no-pager td-agent

# Fluentd should be started if service was stopped before update.
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)

# Test: environmental variables
pid=$(systemctl show fluentd --property=MainPID --value)
env_vars=$(sudo sed -e 's/\x0/\n/g' /proc/$pid/environ)
test $(eval $env_vars && echo $HOME) = "/var/lib/fluent"
test $(eval $env_vars && echo $LOGNAME) = "_fluentd"
test $(eval $env_vars && echo $USER) = "_fluentd"
test $(eval $env_vars && echo $FLUENT_CONF) = "/etc/fluent/fluentd.conf"
test $(eval $env_vars && echo $FLUENT_PACKAGE_LOG_FILE) = "/var/log/fluent/fluentd.log"
test $(eval $env_vars && echo $FLUENT_PLUGIN) = "/etc/fluent/plugin"
test $(eval $env_vars && echo $FLUENT_SOCKET) = "/var/run/fluent/fluentd.sock"

# Test: No error logs
# (v5 default config outputs 'warn' log, so we should check only 'error' and 'fatal' logs)
sleep 3
test -e /var/log/fluent/fluentd.log
(! grep -e '\[error\]' -e '\[fatal\]' /var/log/fluent/fluentd.log)

# Test: Guard duplicated instance
(! sudo /usr/sbin/fluentd)
(! sudo /usr/sbin/fluentd -v)
sudo /usr/sbin/fluentd --dry-run
1 change: 1 addition & 0 deletions fluent-package/yum/systemd-test/commonvar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
distribution=$(cat /etc/system-release-cpe | awk '{print substr($1, index($1, "o"))}' | cut -d: -f2)
version=$(cat /etc/system-release-cpe | awk '{print substr($1, index($1, "o"))}' | cut -d: -f4)
td_agent_version=4.5.2
fluent_package_lts_version=5.0.5

case $distribution in
amazon)
Expand Down
46 changes: 46 additions & 0 deletions fluent-package/yum/systemd-test/downgrade-to-v5-lts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -exu

. $(dirname $0)/commonvar.sh

# Install v5 LTS to register the repository
case $distribution in
amazon)
case $version in
2023)
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2023-fluent-package5-lts.sh | sh
;;
2)
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2-fluent-package5-lts.sh | sh
;;
esac
;;
*)
curl -fsSL https://toolbelt.treasuredata.com/sh/install-redhat-fluent-package5-lts.sh | sh
;;
esac

sudo $DNF remove -y fluent-package

# Install the current
sudo $DNF install -y \
/host/${distribution}/${DISTRIBUTION_VERSION}/x86_64/Packages/fluent-package-[0-9]*.rpm

sudo systemctl enable --now fluentd
systemctl status --no-pager fluentd
systemctl status --no-pager td-agent
main_pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)

# Downgrade to v5 LTS
sudo $DNF downgrade -y fluent-package-${fluent_package_lts_version}

# Test: take over enabled state
systemctl is-enabled fluentd

# Test: service status
systemctl status --no-pager fluentd
systemctl status --no-pager td-agent

# Fluentd should be restarted.
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
79 changes: 79 additions & 0 deletions fluent-package/yum/systemd-test/update-from-v5-lts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

set -exu

. $(dirname $0)/commonvar.sh

# If it update from v5 LTS without stopping Fluentd, Fluentd will be restarted.
# Install v5 LTS
case $distribution in
amazon)
case $version in
2023)
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2023-fluent-package5-lts.sh | sh
;;
2)
curl -fsSL https://toolbelt.treasuredata.com/sh/install-amazon2-fluent-package5-lts.sh | sh
;;
esac
;;
*)
curl -fsSL https://toolbelt.treasuredata.com/sh/install-redhat-fluent-package5-lts.sh | sh
;;
esac

sudo systemctl enable --now fluentd
systemctl status --no-pager fluentd
systemctl status --no-pager td-agent
main_pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)

# Install the current
sudo $DNF install -y \
/host/${distribution}/${DISTRIBUTION_VERSION}/x86_64/Packages/fluent-package-[0-9]*.rpm

# Test: take over enabled state
systemctl is-enabled fluentd

# Test: service status
systemctl status --no-pager fluentd
systemctl status --no-pager td-agent

# Fluentd should be restarted when update from v5 LTS.
test $main_pid -ne $(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)

# Test: environmental variables
pid=$(eval $(systemctl show fluentd --property=MainPID) && echo $MainPID)
env_vars=$(sudo sed -e 's/\x0/\n/g' /proc/$pid/environ)
test $(eval $env_vars && echo $HOME) = "/var/lib/fluent"
test $(eval $env_vars && echo $LOGNAME) = "fluentd"
test $(eval $env_vars && echo $USER) = "fluentd"
test $(eval $env_vars && echo $FLUENT_CONF) = "/etc/fluent/fluentd.conf"
test $(eval $env_vars && echo $FLUENT_PACKAGE_LOG_FILE) = "/var/log/fluent/fluentd.log"
test $(eval $env_vars && echo $FLUENT_PLUGIN) = "/etc/fluent/plugin"
test $(eval $env_vars && echo $FLUENT_SOCKET) = "/var/run/fluent/fluentd.sock"

# Test: No error logs
# (v5 default config outputs 'warn' log, so we should check only 'error' and 'fatal' logs)
sleep 3
test -e /var/log/fluent/fluentd.log
(! grep -e '\[error\]' -e '\[fatal\]' /var/log/fluent/fluentd.log)

# Test: Guard duplicated instance
(! sudo /usr/sbin/fluentd)
(! sudo /usr/sbin/fluentd -v)
sudo /usr/sbin/fluentd --dry-run

# Uninstall
sudo $DNF remove -y fluent-package
sudo systemctl daemon-reload

getent passwd fluentd >/dev/null
getent group fluentd >/dev/null

# `sudo systemctl daemon-reload` clears the service completely.
# (The result of `systemctl status` will be `unfound`)
# Note: RPM does not leave links like `@/etc/systemd/system/fluentd.service`.
# (Different from deb)

(! systemctl status --no-pager td-agent)
(! systemctl status --no-pager fluentd)
Loading