Skip to content

Commit

Permalink
Integration test audit (influxdata#8725)
Browse files Browse the repository at this point in the history
  • Loading branch information
helenosheaa authored Jan 26, 2021
1 parent eda1dbc commit d41569c
Show file tree
Hide file tree
Showing 38 changed files with 305 additions and 202 deletions.
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ running. You can start the containers with:
docker-compose up
```

And run the full test suite with:
To run only the integration tests use:

```
make test-integration
```

To run the full test suite use:
```
make test-all
```
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ go-install:
test:
go test -short $(race_detector) ./...

.PHONY: test-integration
test-integration:
go test -run Integration $(race_detector) ./...

.PHONY: fmt
fmt:
@gofmt -s -w $(filter-out plugins/parsers/influx/machine.go, $(GOFILES))
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
ports:
- "3306:3306"
# removes warning "mbind operation not permitted" enables you to see the docker logs
cap_add:
- SYS_NICE # CAP_SYS_NICE
memcached:
image: memcached
ports:
Expand Down
61 changes: 61 additions & 0 deletions docs/INTEGRATION_TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Integration Tests

To run our current integration test suite:

Running the integration tests requires several docker containers to be
running. You can start the containers with:
```
docker-compose up
```

To run only the integration tests use:

```
make test-integration
```

Use `make docker-kill` to stop the containers.

Contributing integration tests:

- Add Integration to the end of the test name so it will be run with the above command.
- Writes tests where no library is being used in the plugin
- There is poor code coverage
- It has dynamic code that only gets run at runtime eg: SQL

Current areas we have integration tests:

| Area | What it does |
|------------------------------------|-------------------------------------------|
| Inputs: Aerospike | |
| Inputs: Disque | |
| Inputs: Dovecot | |
| Inputs: Mcrouter | |
| Inputs: Memcached | |
| Inputs: Mysql | |
| Inputs: Opcua | |
| Inputs: Openldap | |
| Inputs: Pgbouncer | |
| Inputs: Postgresql | |
| Inputs: Postgresql extensible | |
| Inputs: Procstat / Native windows | |
| Inputs: Prometheus | |
| Inputs: Redis | |
| Inputs: Sqlserver | |
| Inputs: Win perf counters | |
| Inputs: Win services | |
| Inputs: Zookeeper | |
| Outputs: Cratedb / Postgres | |
| Outputs: Elasticsearch | |
| Outputs: Kafka | |
| Outputs: MQTT | |
| Outputs: Nats | |
| Outputs: NSQ | |

Areas we would benefit most from new integration tests:

| Area |
|------------------------------------|
| SNMP |
| MYSQL |
| SQLSERVER |
5 changes: 2 additions & 3 deletions internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ var (
)

func TestRunTimeout(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test due to random failures.")
}
t.Skip("Skipping test due to random failures & a data race when running test-all.")

if sleepbin == "" {
t.Skip("'sleep' binary not available on OS, skipping.")
}
Expand Down
4 changes: 2 additions & 2 deletions logger/event_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func getEventLog(t *testing.T, since time.Time) []Event {
return events.Events
}

func TestEventLog(t *testing.T) {
func TestEventLogIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand All @@ -68,7 +68,7 @@ func TestEventLog(t *testing.T) {
assert.Contains(t, events, Event{Message: "Err message", Level: Error})
}

func TestRestrictedEventLog(t *testing.T) {
func TestRestrictedEventLogIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand Down
20 changes: 10 additions & 10 deletions plugins/inputs/aerospike/aerospike_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestAerospikeStatistics(t *testing.T) {
func TestAerospikeStatisticsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand All @@ -34,7 +34,7 @@ func TestAerospikeStatistics(t *testing.T) {

}

func TestAerospikeStatisticsPartialErr(t *testing.T) {
func TestAerospikeStatisticsPartialErrIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand All @@ -58,7 +58,7 @@ func TestAerospikeStatisticsPartialErr(t *testing.T) {
assert.Equal(t, namespaceName, "test")
}

func TestSelectNamepsaces(t *testing.T) {
func TestSelectNamepsacesIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestSelectNamepsaces(t *testing.T) {
assert.False(t, acc.HasInt64Field("aerospke_namespace", "appeals_tx_remaining"))
}

func TestDisableQueryNamespaces(t *testing.T) {
func TestDisableQueryNamespacesIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand All @@ -119,7 +119,7 @@ func TestDisableQueryNamespaces(t *testing.T) {
assert.True(t, acc.HasMeasurement("aerospike_namespace"))
}

func TestQuerySets(t *testing.T) {
func TestQuerySetsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestQuerySets(t *testing.T) {

}

func TestSelectQuerySets(t *testing.T) {
func TestSelectQuerySetsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestSelectQuerySets(t *testing.T) {

}

func TestDisableTTLHistogram(t *testing.T) {
func TestDisableTTLHistogramIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand All @@ -238,7 +238,7 @@ func TestDisableTTLHistogram(t *testing.T) {

assert.False(t, acc.HasMeasurement("aerospike_histogram_ttl"))
}
func TestTTLHistogram(t *testing.T) {
func TestTTLHistogramIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
} else {
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestTTLHistogram(t *testing.T) {
assert.True(t, FindTagValue(&acc, "aerospike_histogram_ttl", "namespace", "test"))

}
func TestDisableObjectSizeLinearHistogram(t *testing.T) {
func TestDisableObjectSizeLinearHistogramIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
}
Expand All @@ -286,7 +286,7 @@ func TestDisableObjectSizeLinearHistogram(t *testing.T) {

assert.False(t, acc.HasMeasurement("aerospike_histogram_object_size_linear"))
}
func TestObjectSizeLinearHistogram(t *testing.T) {
func TestObjectSizeLinearHistogramIntegration(t *testing.T) {

if testing.Short() {
t.Skip("Skipping aerospike integration tests.")
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/disque/disque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestDisqueGeneratesMetrics(t *testing.T) {
func TestDisqueGeneratesMetricsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestDisqueGeneratesMetrics(t *testing.T) {
acc.AssertContainsFields(t, "disque", fields)
}

func TestDisqueCanPullStatsFromMultipleServers(t *testing.T) {
func TestDisqueCanPullStatsFromMultipleServersIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand Down
14 changes: 12 additions & 2 deletions plugins/inputs/dns_query/dns_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ func TestGatheringRootDomain(t *testing.T) {
"server": "8.8.8.8",
"domain": ".",
"record_type": "MX",
"rcode": "NOERROR",
"result": "success",
}
fields := map[string]interface{}{
"rcode_value": int(0),
"result_code": uint64(0),
}
fields := map[string]interface{}{}

err := acc.GatherError(dnsConfig.Gather)
assert.NoError(t, err)
Expand All @@ -93,8 +98,13 @@ func TestMetricContainsServerAndDomainAndRecordTypeTags(t *testing.T) {
"server": "8.8.8.8",
"domain": "google.com",
"record_type": "NS",
"rcode": "NOERROR",
"result": "success",
}
fields := map[string]interface{}{
"rcode_value": int(0),
"result_code": uint64(0),
}
fields := map[string]interface{}{}

err := acc.GatherError(dnsConfig.Gather)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/dovecot/dovecot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestDovecot(t *testing.T) {
func TestDovecotIntegration(t *testing.T) {

if testing.Short() {
t.Skip("Skipping integration test in short mode")
Expand Down
91 changes: 70 additions & 21 deletions plugins/inputs/mcrouter/mcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAddressParsing(t *testing.T) {
}
}

func TestMcrouterGeneratesMetrics(t *testing.T) {
func TestMcrouterGeneratesMetricsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand All @@ -58,26 +58,75 @@ func TestMcrouterGeneratesMetrics(t *testing.T) {
err := acc.GatherError(m.Gather)
require.NoError(t, err)

intMetrics := []string{"uptime", "num_servers", "num_servers_new", "num_servers_up",
"num_servers_down", "num_servers_closed", "num_clients",
"num_suspect_servers", "destination_batches_sum", "destination_requests_sum",
"outstanding_route_get_reqs_queued", "outstanding_route_update_reqs_queued",
"outstanding_route_get_avg_queue_size", "outstanding_route_update_avg_queue_size",
"outstanding_route_get_avg_wait_time_sec", "outstanding_route_update_avg_wait_time_sec",
"retrans_closed_connections", "destination_pending_reqs", "destination_inflight_reqs",
"destination_batch_size", "asynclog_requests", "proxy_reqs_processing",
"proxy_reqs_waiting", "client_queue_notify_period",
"ps_num_minor_faults", "ps_num_major_faults",
"ps_vsize", "ps_rss", "fibers_allocated", "fibers_pool_size", "fibers_stack_high_watermark",
"successful_client_connections", "duration_us", "destination_max_pending_reqs",
"destination_max_inflight_reqs", "retrans_per_kbyte_max", "cmd_get_count", "cmd_delete_out",
"cmd_lease_get", "cmd_set", "cmd_get_out_all", "cmd_get_out", "cmd_lease_set_count",
"cmd_other_out_all", "cmd_lease_get_out", "cmd_set_count", "cmd_lease_set_out",
"cmd_delete_count", "cmd_other", "cmd_delete", "cmd_get", "cmd_lease_set", "cmd_set_out",
"cmd_lease_get_count", "cmd_other_out", "cmd_lease_get_out_all", "cmd_set_out_all",
"cmd_other_count", "cmd_delete_out_all", "cmd_lease_set_out_all"}

floatMetrics := []string{"rusage_system", "rusage_user", "ps_user_time_sec", "ps_system_time_sec"}
intMetrics := []string{
"uptime",
// "num_servers",
// "num_servers_new",
// "num_servers_up",
// "num_servers_down",
// "num_servers_closed",
// "num_clients",
// "num_suspect_servers",
// "destination_batches_sum",
// "destination_requests_sum",
// "outstanding_route_get_reqs_queued",
// "outstanding_route_update_reqs_queued",
// "outstanding_route_get_avg_queue_size",
// "outstanding_route_update_avg_queue_size",
// "outstanding_route_get_avg_wait_time_sec",
// "outstanding_route_update_avg_wait_time_sec",
// "retrans_closed_connections",
// "destination_pending_reqs",
// "destination_inflight_reqs",
// "destination_batch_size",
// "asynclog_requests",
// "proxy_reqs_processing",
// "proxy_reqs_waiting",
// "client_queue_notify_period",
// "ps_num_minor_faults",
// "ps_num_major_faults",
// "ps_vsize",
// "ps_rss",
// "fibers_allocated",
// "fibers_pool_size",
// "fibers_stack_high_watermark",
// "successful_client_connections",
// "duration_us",
// "destination_max_pending_reqs",
// "destination_max_inflight_reqs",
// "retrans_per_kbyte_max",
// "cmd_get_count",
// "cmd_delete_out",
// "cmd_lease_get",
"cmd_set",
// "cmd_get_out_all",
// "cmd_get_out",
// "cmd_lease_set_count",
// "cmd_other_out_all",
// "cmd_lease_get_out",
// "cmd_set_count",
// "cmd_lease_set_out",
// "cmd_delete_count",
// "cmd_other",
// "cmd_delete",
"cmd_get",
// "cmd_lease_set",
// "cmd_set_out",
// "cmd_lease_get_count",
// "cmd_other_out",
// "cmd_lease_get_out_all",
// "cmd_set_out_all",
// "cmd_other_count",
// "cmd_delete_out_all",
// "cmd_lease_set_out_all"
}

floatMetrics := []string{
"rusage_system",
"rusage_user",
// "ps_user_time_sec",
// "ps_system_time_sec",
}

for _, metric := range intMetrics {
assert.True(t, acc.HasInt64Field("mcrouter", metric), metric)
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/memcached/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestMemcachedGeneratesMetrics(t *testing.T) {
func TestMemcachedGeneratesMetricsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand Down
Loading

0 comments on commit d41569c

Please sign in to comment.