From 6a60f226cc72c482a71e4977dcbbca5f77589c74 Mon Sep 17 00:00:00 2001 From: Tom Hendrikx Date: Wed, 11 Oct 2023 18:06:12 +0200 Subject: [PATCH] Add script to run tests inside a docker container easily --- .github/workflows/run_tests.yml | 4 ++-- README.md | 2 +- runtests.sh | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100755 runtests.sh diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index f178628..6617931 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -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 diff --git a/README.md b/README.md index 0f9dfa1..f747ec7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/runtests.sh b/runtests.sh new file mode 100755 index 0000000..e08eba8 --- /dev/null +++ b/runtests.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -eux + +git submodule update --init + +docker build -t postfix-grok-patterns-runtests - <