Skip to content

Commit

Permalink
Add script to run tests inside a docker container easily
Browse files Browse the repository at this point in the history
  • Loading branch information
whyscream committed Oct 11, 2023
1 parent 0652d66 commit 6a60f22
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
ruby-version: '3.2'
- run: gem install jls-grok minitest
- run: ruby test/test.rb
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Tests

In the `test/` directory, there is a test suite that tries to make sure that no previously supported log line will break because of changing common patterns and such. It also returns results a lot faster than doing `sudo service logstash restart` :-).

The test suite needs the patterns provided by Logstash, you can easily pull these from github by running `git submodule update --init`. To run the test suite, you also need `ruby 2.2` or higher, and the `jls-grok` and `minitest` gems. Then simply execute `ruby test/test.rb`.
The test suite needs the patterns provided by Logstash, you can easily pull these from github by running `git submodule update --init`. To run the test suite, you also need `ruby 2.2` or higher, and the `jls-grok` and `minitest` gems. Then simply execute `ruby test/test.rb`. NOTE: The whole test process can now be executed inside a docker container, simply by running the `runtests.sh` script.

Adding new test cases can easily be done by creating new yaml files in the test directory. Each file specifies a grok pattern to validate, a sample log line, and a list of expected results.

Expand Down
13 changes: 13 additions & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -eux

git submodule update --init

docker build -t postfix-grok-patterns-runtests - <<EOF
FROM ruby:slim
RUN gem install jls-grok minitest
EOF

TESTPATH=/runtests
docker run -v $(pwd):"${TESTPATH}" postfix-grok-patterns-runtests sh -c "cd ${TESTPATH} && ruby test/test.rb"

0 comments on commit 6a60f22

Please sign in to comment.