Skip to content

Commit

Permalink
Merge pull request #14 from claranet/add_ci
Browse files Browse the repository at this point in the history
Run tests in Github Actions against Zabbix 3.0, 3.2, 3.4, 4.0, 4.2, 4.4, 5.0, 5.2
  • Loading branch information
pdecat authored Oct 3, 2022
2 parents 142bcea + b1877b9 commit afeebbf
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ on:
branches: [ "master" ]

jobs:
test:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/test-zabbix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Test
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
zabbix_version: ["3.0", "3.2", "3.4", "4.0", "4.2", "4.4", "5.0", "5.2"]

services:
mysql-server:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
ports:
- 3306:3306
# needed because the mysql container does not provide a healthcheck
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10

zabbix-server:
image: zabbix/zabbix-server-mysql:alpine-${{ matrix.zabbix_version }}-latest
env:
DB_SERVER_HOST: mysql-server
DB_SERVER_PORT: 3306
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_USER: zabbix
ports:
- 10051:10051

zabbix-web-nginx-mysql:
image: zabbix/zabbix-web-nginx-mysql:alpine-${{ matrix.zabbix_version }}-latest
env:
ZBX_SERVER_HOST: zabbix-server
ZBX_SERVER_PORT: 10051
DB_SERVER_HOST: mysql-server
DB_SERVER_PORT: 3306
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_USER: zabbix
ports:
- 8080:${{ contains(fromJson('["3.2", "3.4", "4.2"]'), matrix.zabbix_version) && '80' || '8080' }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go 1.18
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Test
env:
TEST_ZABBIX_VERBOSE: 1
TEST_ZABBIX_URL: http://localhost:8080/api_jsonrpc.php
TEST_ZABBIX_USER: Admin
TEST_ZABBIX_PASSWORD: zabbix
run: |
while true ; do
output=$(curl -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"user.login","params":{"user":"'$TEST_ZABBIX_USER'","password":"'$TEST_ZABBIX_PASSWORD'"},"id":1,"auth":null}' $TEST_ZABBIX_URL || echo error)
echo $output
echo $output | grep -v error > /dev/null && break
echo "Waiting 5s for Zabbix Server to be ready..."
sleep 5
done
go test -v
4 changes: 2 additions & 2 deletions base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func TestBadCalls(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if res.Error.Code != -32602 {
t.Errorf("Expected code -32602, got %s", res.Error)
if res.Error.Code != -32600 && res.Error.Code != -32602 {
t.Errorf("Expected code -32600 or -32602 depending on Zabbix Server version, got %s", res.Error)
}
}

Expand Down

0 comments on commit afeebbf

Please sign in to comment.