Skip to content

Commit

Permalink
Merge branch 'failure-inte-tests' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed Sep 16, 2024
2 parents d43ca87 + ef10683 commit 8650f47
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 46 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@ jobs:

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

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Test Package
run: go test -v "./go-zabbix/.."

- name: Test Types Package
run: go test -v "./types/..."
- name: Test
run: go test -v -short "./..."

integration:
timeout-minutes: 31
Expand All @@ -40,25 +37,31 @@ jobs:
zabbix:
- version: "4.0"
suffix: "-latest"
postgress_version: "15-alpine"
- version: "5.0"
suffix: "-latest"
postgress_version: "15-alpine"
- version: "6.0"
suffix: "-latest"
postgress_version: "15-alpine"
- version: "6.2"
suffix: "-latest"
postgress_version: "15-alpine"
- version: "6.4"
suffix: "-latest"
- version: "7.0" # will become 7.0
postgress_version: "16-alpine"
- version: "7.0"
suffix: "-latest"
postgress_version: "16-alpine"

name: "Zabbix ${{ matrix.zabbix.version }} Integration Tests"

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

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'

Expand All @@ -67,18 +70,24 @@ jobs:
env:
ZBX_VERSION: "${{ matrix.zabbix.version }}"
ZBX_VERSION_SUFFIX: "${{ matrix.zabbix.suffix }}"
POSTGRES_VERSION: "${{ matrix.zabbix.postgress_version }}"

- name: Wait for Zabbix server to become available
uses: iFaxity/[email protected]
id: wait_for_server
uses: iFaxity/[email protected]
with:
resource: tcp:localhost:10051
timeout: 900000
timeout: 300000
interval: 10000
delay: 60000
log: true

- name: Server logs
if: always() && steps.wait_for_server.outcome == 'failure'
run: docker compose -f "docker-compose.yml" logs server

- name: Test
run: go test -v "./test/integration/..."
run: go test -v -run Integration "./..."

- name: Stop containers
if: always()
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
tests: unittests integration

unittests:
go test -v "./go-zabbix/.."
go test -v "./types/..."
go test -v -short "./..."

integration:
go test -v "./test/integration/..."
go test -v -run Integration "./..."
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ func main() {
Running the unit tests:

```bash
go test -v "./go-zabbix/.."
go test -v "./types/..."
go test -v -short "./..."
# or:
make unittests
```
Expand All @@ -124,7 +123,7 @@ export ZBX_VERSION=6.4
docker compose up -d
# server should be running in a minute
# run tests:
go test -v "./test/integration/..."
go test -v -run Integration "./..."
# or:
make integration
```
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- POSTGRES_DB=zabbix

database:
image: postgres
image: postgres:${POSTGRES_VERSION:-alpine}
environment:
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
Expand Down
6 changes: 5 additions & 1 deletion test/integration/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestActions(t *testing.T) {
func TestActionsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.ActionGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestAlerts(t *testing.T) {
func TestAlertsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.AlertGetParams{
Expand Down
6 changes: 5 additions & 1 deletion test/integration/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestEvents(t *testing.T) {
func TestEventsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.EventGetParams{
Expand Down
6 changes: 5 additions & 1 deletion test/integration/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestHistories(t *testing.T) {
func TestHistoriesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.HistoryGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/host_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestHostInterfaces(t *testing.T) {
func TestHostInterfacesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.HostInterfaceGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/hostgroups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestHostgroups(t *testing.T) {
func TestHostgroupsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.HostgroupGetParams{}
Expand Down
89 changes: 74 additions & 15 deletions test/integration/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,47 @@ func testHost(t *testing.T, params zabbix.HostGetParams) {
t.Logf("Validated %d Hosts", len(hosts))
}

func TestHostsTemplates(t *testing.T) {
func TestHostsTemplatesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
IncludeTemplates: true,
}

testHost(t, params)
}

func TestHostsGroups(t *testing.T) {
func TestHostsGroupsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectGroups: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsApplications(t *testing.T) {
func TestHostsApplicationsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectApplications: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsDiscoveries(t *testing.T) {
func TestHostsDiscoveriesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectDiscoveries: zabbix.SelectExtendedOutput,
}
Expand All @@ -63,7 +79,10 @@ func TestHostsDiscoveries(t *testing.T) {

}

func TestHostsDiscoveryRule(t *testing.T) {
func TestHostsDiscoveryRuleIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectDiscoveryRule: zabbix.SelectExtendedOutput,
Expand All @@ -72,79 +91,119 @@ func TestHostsDiscoveryRule(t *testing.T) {
testHost(t, params)
}

func TestHostsGraphs(t *testing.T) {
func TestHostsGraphsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectGraphs: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsHostDiscovery(t *testing.T) {
func TestHostsHostDiscoveryIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectHostDiscovery: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsWebScenarios(t *testing.T) {
func TestHostsWebScenariosIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectWebScenarios: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsInterfaces(t *testing.T) {
func TestHostsInterfacesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectInterfaces: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsInventory(t *testing.T) {
func TestHostsInventoryIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectInventory: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsItems(t *testing.T) {
func TestHostsItemsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectItems: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsMacros(t *testing.T) {
func TestHostsMacrosIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectMacros: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsParentTemplates(t *testing.T) {
func TestHostsParentTemplatesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectParentTemplates: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsScreens(t *testing.T) {
func TestHostsScreensIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectScreens: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsTriggers(t *testing.T) {
func TestHostsTriggersIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectTriggers: zabbix.SelectExtendedOutput,
}
Expand Down
Loading

0 comments on commit 8650f47

Please sign in to comment.