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

Fix host destruction #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
87 changes: 87 additions & 0 deletions .github/workflows/test-zabbix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Test
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Tests
run: |
make test

testacc:
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
zabbix_version: ["3.0", "3.2", "3.4", "4.0", "4.2", "4.4", "5.0", "5.2", "5.4", "6.0", "6.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: Acceptance Tests
env:
ZABBIX_SERVER_URL: http://localhost:8080/api_jsonrpc.php
ZABBIX_USER: Admin
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":"'$ZABBIX_USER'","password":"'$ZABBIX_PASSWORD'"},"id":1,"auth":null}' $ZABBIX_SERVER_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

make testacc
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/claranet/terraform-provider-zabbix
go 1.18

require (
github.com/claranet/go-zabbix-api v1.0.0
github.com/claranet/go-zabbix-api v1.0.2
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0
)
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/claranet/go-zabbix-api v1.0.0 h1:sV001+191+ZLPx7ghck83KG3EavKk/xlf7F6uF8n2sM=
github.com/claranet/go-zabbix-api v1.0.0/go.mod h1:+d6XCoI7I8fy1z8lch6FJUmFrp5P8QNySnw4nnAcCP0=
github.com/claranet/go-zabbix-api v1.0.1 h1:eMfGm2TwgLD+tGqKKWA/izeu01PAYIPu8pdy2nCxX7k=
github.com/claranet/go-zabbix-api v1.0.1/go.mod h1:iSG6GXVBcmvHDLwh7MopqED+tI1Jbe4rFADFdBBZXfI=
github.com/claranet/go-zabbix-api v1.0.2 h1:R2vaHHYB9jpamMg2kQLUZy1cqvRw4fOnWuCr6Tm+OHg=
github.com/claranet/go-zabbix-api v1.0.2/go.mod h1:ZK0I4NKOPCumEza6i8R3iHkAk79munoWIqCxCvpnI/4=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand Down