Skip to content

Commit e1b98c7

Browse files
committed
add package tests
This script should work with td-agent v3.1.1 (rpm/deb/msi) or later. (Embedded Fluentd version must be v1) Signed-off-by: Daijiro Fukuda <[email protected]>
1 parent 7ec076c commit e1b98c7

12 files changed

+314
-1
lines changed

.github/workflows/main.yml

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- ruby: '2.7.1'
6666
fluentd: '1.11.1'
6767
runs-on: ${{ matrix.os }}
68-
name: Gem test with Ruby ${{ matrix.ruby }} on ${{ matrix.os }}
68+
name: Gem with Ruby ${{ matrix.ruby }} on ${{ matrix.os }}
6969
steps:
7070
- uses: actions/checkout@v4
7171
- uses: ruby/setup-ruby@v1
@@ -88,3 +88,79 @@ jobs:
8888
if: ${{ matrix.shell == 'cmd' }}
8989
run: test/script/command-test.bat
9090
shell: cmd
91+
92+
gem-test-with-package:
93+
needs: build
94+
strategy:
95+
fail-fast: false
96+
matrix:
97+
test:
98+
- td-agent-v3.1.1.el7-test.bash
99+
- td-agent-v4.0.0.el8-test.bash
100+
- fluent-package-v5.0.1.el9-test.bash
101+
- td-agent-v3.1.1.xenial-test.bash
102+
- td-agent-v4.0.0.focal-test.bash
103+
- fluent-package-v5.0.1.jammy-test.bash
104+
include:
105+
- test: td-agent-v3.1.1.el7-test.bash
106+
vm: centos-7
107+
- test: td-agent-v4.0.0.el8-test.bash
108+
vm: rockylinux-8
109+
- test: fluent-package-v5.0.1.el9-test.bash
110+
vm: almalinux-9
111+
- test: td-agent-v3.1.1.xenial-test.bash
112+
vm: ubuntu-xenial
113+
- test: td-agent-v4.0.0.focal-test.bash
114+
vm: ubuntu-focal
115+
- test: fluent-package-v5.0.1.jammy-test.bash
116+
vm: ubuntu-jammy
117+
runs-on: ubuntu-latest
118+
name: ${{ matrix.test }}
119+
steps:
120+
- uses: actions/checkout@v4
121+
- uses: actions/download-artifact@v4
122+
with:
123+
name: gem
124+
path: pkg
125+
- name: Set up VirtualBox
126+
run: |
127+
sudo apt update
128+
sudo apt install -y virtualbox
129+
- name: Set up Vagrant
130+
run: |
131+
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
132+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
133+
sudo apt update && sudo apt install -y vagrant
134+
vagrant --version
135+
vagrant status
136+
- name: Test
137+
run: |
138+
vagrant up ${{ matrix.vm }}
139+
vagrant ssh ${{ matrix.vm }} -- /vagrant/test/script/${{ matrix.test }}
140+
141+
gem-test-with-msi-package:
142+
needs: build
143+
strategy:
144+
fail-fast: false
145+
matrix:
146+
test:
147+
- td-agent-v3.1.1.msi-test.ps1
148+
- td-agent-v4.0.0.msi-test.ps1
149+
- fluent-package-v5.0.1.msi-test.ps1
150+
include:
151+
- test: td-agent-v3.1.1.msi-test.ps1
152+
os: windows-2019
153+
- test: td-agent-v4.0.0.msi-test.ps1
154+
os: windows-2019
155+
- test: fluent-package-v5.0.1.msi-test.ps1
156+
os: windows-latest
157+
runs-on: ${{ matrix.os }}
158+
name: ${{ matrix.test }}
159+
steps:
160+
- uses: actions/checkout@v4
161+
- uses: actions/download-artifact@v4
162+
with:
163+
name: gem
164+
path: pkg
165+
- name: Test
166+
run: test/script/${{ matrix.test }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/spec/reports/
88
/tmp/
99
Gemfile.lock
10+
.vagrant

Vagrantfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5+
VAGRANTFILE_API_VERSION = "2"
6+
7+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8+
vms = [
9+
{
10+
:id => "ubuntu-xenial",
11+
:box => "bento/ubuntu-16.04",
12+
},
13+
{
14+
:id => "ubuntu-focal",
15+
:box => "bento/ubuntu-20.04",
16+
},
17+
{
18+
:id => "ubuntu-jammy",
19+
:box => "bento/ubuntu-22.04",
20+
},
21+
{
22+
:id => "centos-7",
23+
:box => "bento/centos-7",
24+
},
25+
{
26+
:id => "rockylinux-8",
27+
:box => "bento/rockylinux-8",
28+
},
29+
{
30+
:id => "almalinux-9",
31+
:box => "bento/almalinux-9",
32+
},
33+
]
34+
35+
n_cpus = ENV["BOX_N_CPUS"]&.to_i || 2
36+
memory = ENV["BOX_MEMORY"]&.to_i || 2048
37+
vms.each_with_index do |vm, idx|
38+
id = vm[:id]
39+
box = vm[:box] || id
40+
config.vm.define(id) do |node|
41+
node.vm.box = box
42+
node.vm.provider("virtualbox") do |virtual_box|
43+
virtual_box.cpus = n_cpus if n_cpus
44+
virtual_box.memory = memory if memory
45+
end
46+
end
47+
end
48+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -exu
4+
5+
curl -OL "https://s3.amazonaws.com/packages.treasuredata.com/lts/5/redhat/9/x86_64/fluent-package-5.0.1-1.el9.x86_64.rpm"
6+
sudo dnf install -y ./fluent-package-5.0.1-1.el9.x86_64.rpm
7+
8+
sudo fluent-gem install /vagrant/pkg/*
9+
10+
tailcheck=/opt/fluent/bin/tailcheck
11+
12+
$tailcheck --version
13+
$tailcheck --help
14+
$tailcheck /vagrant/test/data/pos_normal
15+
(! $tailcheck /vagrant/test/data/pos_normal /vagrant/test/data/pos_duplicate_unwatched_path)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -exu
4+
5+
curl -OL "https://s3.amazonaws.com/packages.treasuredata.com/lts/5/ubuntu/jammy/pool/contrib/f/fluent-package/fluent-package_5.0.1-1_amd64.deb"
6+
sudo apt install -y ./fluent-package_5.0.1-1_amd64.deb
7+
8+
sudo fluent-gem install /vagrant/pkg/*
9+
10+
tailcheck=/opt/fluent/bin/tailcheck
11+
12+
$tailcheck --version
13+
$tailcheck --help
14+
$tailcheck /vagrant/test/data/pos_normal
15+
(! $tailcheck /vagrant/test/data/pos_normal /vagrant/test/data/pos_duplicate_unwatched_path)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$ErrorActionPreference = "Stop"
2+
$ProgressPreference = "SilentlyContinue"
3+
Set-PSDebug -Trace 1
4+
5+
$msi = "fluent-package-5.0.1-x64.msi"
6+
Invoke-WebRequest "https://s3.amazonaws.com/packages.treasuredata.com/5/windows/$msi" -OutFile $msi
7+
8+
Start-Process msiexec -ArgumentList "/i", $msi, "/quiet" -Wait
9+
10+
function Test-Cmd([string]$Cmd, [switch]$ExpectFail) {
11+
cmd.exe /c "call C:\\opt\\fluent\\fluent-package-prompt.bat && $Cmd"
12+
13+
$exitcode = $LastExitCode
14+
if ($ExpectFail) {
15+
if ($exitcode -eq 0) {
16+
throw "Command failed."
17+
}
18+
} else {
19+
if ($exitcode -ne 0) {
20+
throw "Command did not fail."
21+
}
22+
}
23+
}
24+
25+
Test-Cmd "fluent-gem install pkg/*"
26+
Test-Cmd "tailcheck --version"
27+
Test-Cmd "tailcheck --help"
28+
Test-Cmd "tailcheck test/data/pos_normal"
29+
Test-Cmd "tailcheck test/data/pos_normal test/data/pos_duplicate_unwatched_path" -ExpectFail
30+
31+
exit 0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -exu
4+
5+
sudo sed -i -e 's/^mirrorlist/#mirrorlist/g' \
6+
-e 's/^#baseurl/baseurl/g' \
7+
-e 's,mirror.centos.org/centos/$releasever,vault.centos.org/7.9.2009,g' \
8+
/etc/yum.repos.d/CentOS-Base.repo
9+
10+
curl -OL "https://s3.amazonaws.com/packages.treasuredata.com/3/redhat/7/x86_64/td-agent-3.1.1-0.el7.x86_64.rpm"
11+
sudo yum install -y ./td-agent-3.1.1-0.el7.x86_64.rpm
12+
13+
sudo td-agent-gem install /vagrant/pkg/*
14+
15+
tailcheck=/opt/td-agent/embedded/lib/ruby/gems/2.4.0/bin/tailcheck
16+
17+
$tailcheck --version
18+
$tailcheck --help
19+
$tailcheck /vagrant/test/data/pos_normal
20+
(! $tailcheck /vagrant/test/data/pos_normal /vagrant/test/data/pos_duplicate_unwatched_path)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$ErrorActionPreference = "Stop"
2+
$ProgressPreference = "SilentlyContinue"
3+
Set-PSDebug -Trace 1
4+
5+
$msi = "td-agent-3.1.1-0-x64.msi"
6+
Invoke-WebRequest "https://s3.amazonaws.com/packages.treasuredata.com/3/windows/$msi" -OutFile $msi
7+
8+
Start-Process msiexec -ArgumentList "/i", $msi, "/quiet" -Wait
9+
10+
function Test-Cmd([string]$Cmd, [switch]$ExpectFail) {
11+
cmd.exe /c "call C:\\opt\\td-agent\\td-agent-prompt.bat && $Cmd"
12+
13+
$exitcode = $LastExitCode
14+
if ($ExpectFail) {
15+
if ($exitcode -eq 0) {
16+
throw "Command failed."
17+
}
18+
} else {
19+
if ($exitcode -ne 0) {
20+
throw "Command did not fail."
21+
}
22+
}
23+
}
24+
25+
Test-Cmd "td-agent-gem install pkg/*"
26+
Test-Cmd "tailcheck --version"
27+
Test-Cmd "tailcheck --help"
28+
Test-Cmd "tailcheck test/data/pos_normal"
29+
Test-Cmd "tailcheck test/data/pos_normal test/data/pos_duplicate_unwatched_path" -ExpectFail
30+
31+
exit 0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -exu
4+
5+
curl -OL "https://s3.amazonaws.com/packages.treasuredata.com/3/ubuntu/xenial/pool/contrib/t/td-agent/td-agent_3.1.1-0_amd64.deb"
6+
sudo apt install -y ./td-agent_3.1.1-0_amd64.deb
7+
8+
sudo td-agent-gem install /vagrant/pkg/*
9+
10+
tailcheck=/opt/td-agent/embedded/lib/ruby/gems/2.4.0/bin/tailcheck
11+
12+
$tailcheck --version
13+
$tailcheck --help
14+
$tailcheck /vagrant/test/data/pos_normal
15+
(! $tailcheck /vagrant/test/data/pos_normal /vagrant/test/data/pos_duplicate_unwatched_path)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -exu
4+
5+
curl -OL "https://s3.amazonaws.com/packages.treasuredata.com/4/redhat/8/x86_64/td-agent-4.0.0-1.el8.x86_64.rpm"
6+
sudo dnf install -y ./td-agent-4.0.0-1.el8.x86_64.rpm
7+
8+
sudo td-agent-gem install /vagrant/pkg/*
9+
10+
tailcheck=/opt/td-agent/bin/tailcheck
11+
12+
$tailcheck --version
13+
$tailcheck --help
14+
$tailcheck /vagrant/test/data/pos_normal
15+
(! $tailcheck /vagrant/test/data/pos_normal /vagrant/test/data/pos_duplicate_unwatched_path)

0 commit comments

Comments
 (0)