Skip to content

Commit d41569c

Browse files
authored
Integration test audit (influxdata#8725)
1 parent eda1dbc commit d41569c

38 files changed

+305
-202
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ running. You can start the containers with:
6161
docker-compose up
6262
```
6363

64-
And run the full test suite with:
64+
To run only the integration tests use:
65+
66+
```
67+
make test-integration
68+
```
69+
70+
To run the full test suite use:
6571
```
6672
make test-all
6773
```

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ go-install:
9898
test:
9999
go test -short $(race_detector) ./...
100100

101+
.PHONY: test-integration
102+
test-integration:
103+
go test -run Integration $(race_detector) ./...
104+
101105
.PHONY: fmt
102106
fmt:
103107
@gofmt -s -w $(filter-out plugins/parsers/influx/machine.go, $(GOFILES))

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ services:
4040
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
4141
ports:
4242
- "3306:3306"
43+
# removes warning "mbind operation not permitted" enables you to see the docker logs
44+
cap_add:
45+
- SYS_NICE # CAP_SYS_NICE
4346
memcached:
4447
image: memcached
4548
ports:

docs/INTEGRATION_TESTS.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Integration Tests
2+
3+
To run our current integration test suite:
4+
5+
Running the integration tests requires several docker containers to be
6+
running. You can start the containers with:
7+
```
8+
docker-compose up
9+
```
10+
11+
To run only the integration tests use:
12+
13+
```
14+
make test-integration
15+
```
16+
17+
Use `make docker-kill` to stop the containers.
18+
19+
Contributing integration tests:
20+
21+
- Add Integration to the end of the test name so it will be run with the above command.
22+
- Writes tests where no library is being used in the plugin
23+
- There is poor code coverage
24+
- It has dynamic code that only gets run at runtime eg: SQL
25+
26+
Current areas we have integration tests:
27+
28+
| Area | What it does |
29+
|------------------------------------|-------------------------------------------|
30+
| Inputs: Aerospike | |
31+
| Inputs: Disque | |
32+
| Inputs: Dovecot | |
33+
| Inputs: Mcrouter | |
34+
| Inputs: Memcached | |
35+
| Inputs: Mysql | |
36+
| Inputs: Opcua | |
37+
| Inputs: Openldap | |
38+
| Inputs: Pgbouncer | |
39+
| Inputs: Postgresql | |
40+
| Inputs: Postgresql extensible | |
41+
| Inputs: Procstat / Native windows | |
42+
| Inputs: Prometheus | |
43+
| Inputs: Redis | |
44+
| Inputs: Sqlserver | |
45+
| Inputs: Win perf counters | |
46+
| Inputs: Win services | |
47+
| Inputs: Zookeeper | |
48+
| Outputs: Cratedb / Postgres | |
49+
| Outputs: Elasticsearch | |
50+
| Outputs: Kafka | |
51+
| Outputs: MQTT | |
52+
| Outputs: Nats | |
53+
| Outputs: NSQ | |
54+
55+
Areas we would benefit most from new integration tests:
56+
57+
| Area |
58+
|------------------------------------|
59+
| SNMP |
60+
| MYSQL |
61+
| SQLSERVER |

internal/internal_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ var (
5252
)
5353

5454
func TestRunTimeout(t *testing.T) {
55-
if testing.Short() {
56-
t.Skip("Skipping test due to random failures.")
57-
}
55+
t.Skip("Skipping test due to random failures & a data race when running test-all.")
56+
5857
if sleepbin == "" {
5958
t.Skip("'sleep' binary not available on OS, skipping.")
6059
}

logger/event_logger_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func getEventLog(t *testing.T, since time.Time) []Event {
4545
return events.Events
4646
}
4747

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

71-
func TestRestrictedEventLog(t *testing.T) {
71+
func TestRestrictedEventLogIntegration(t *testing.T) {
7272
if testing.Short() {
7373
t.Skip("Skipping integration test in short mode")
7474
}

plugins/inputs/aerospike/aerospike_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/stretchr/testify/require"
1010
)
1111

12-
func TestAerospikeStatistics(t *testing.T) {
12+
func TestAerospikeStatisticsIntegration(t *testing.T) {
1313
if testing.Short() {
1414
t.Skip("Skipping aerospike integration tests.")
1515
}
@@ -34,7 +34,7 @@ func TestAerospikeStatistics(t *testing.T) {
3434

3535
}
3636

37-
func TestAerospikeStatisticsPartialErr(t *testing.T) {
37+
func TestAerospikeStatisticsPartialErrIntegration(t *testing.T) {
3838
if testing.Short() {
3939
t.Skip("Skipping aerospike integration tests.")
4040
}
@@ -58,7 +58,7 @@ func TestAerospikeStatisticsPartialErr(t *testing.T) {
5858
assert.Equal(t, namespaceName, "test")
5959
}
6060

61-
func TestSelectNamepsaces(t *testing.T) {
61+
func TestSelectNamepsacesIntegration(t *testing.T) {
6262
if testing.Short() {
6363
t.Skip("Skipping aerospike integration tests.")
6464
}
@@ -92,7 +92,7 @@ func TestSelectNamepsaces(t *testing.T) {
9292
assert.False(t, acc.HasInt64Field("aerospke_namespace", "appeals_tx_remaining"))
9393
}
9494

95-
func TestDisableQueryNamespaces(t *testing.T) {
95+
func TestDisableQueryNamespacesIntegration(t *testing.T) {
9696
if testing.Short() {
9797
t.Skip("Skipping aerospike integration tests.")
9898
}
@@ -119,7 +119,7 @@ func TestDisableQueryNamespaces(t *testing.T) {
119119
assert.True(t, acc.HasMeasurement("aerospike_namespace"))
120120
}
121121

122-
func TestQuerySets(t *testing.T) {
122+
func TestQuerySetsIntegration(t *testing.T) {
123123
if testing.Short() {
124124
t.Skip("Skipping aerospike integration tests.")
125125
}
@@ -168,7 +168,7 @@ func TestQuerySets(t *testing.T) {
168168

169169
}
170170

171-
func TestSelectQuerySets(t *testing.T) {
171+
func TestSelectQuerySetsIntegration(t *testing.T) {
172172
if testing.Short() {
173173
t.Skip("Skipping aerospike integration tests.")
174174
}
@@ -218,7 +218,7 @@ func TestSelectQuerySets(t *testing.T) {
218218

219219
}
220220

221-
func TestDisableTTLHistogram(t *testing.T) {
221+
func TestDisableTTLHistogramIntegration(t *testing.T) {
222222
if testing.Short() {
223223
t.Skip("Skipping aerospike integration tests.")
224224
}
@@ -238,7 +238,7 @@ func TestDisableTTLHistogram(t *testing.T) {
238238

239239
assert.False(t, acc.HasMeasurement("aerospike_histogram_ttl"))
240240
}
241-
func TestTTLHistogram(t *testing.T) {
241+
func TestTTLHistogramIntegration(t *testing.T) {
242242
if testing.Short() {
243243
t.Skip("Skipping aerospike integration tests.")
244244
} else {
@@ -266,7 +266,7 @@ func TestTTLHistogram(t *testing.T) {
266266
assert.True(t, FindTagValue(&acc, "aerospike_histogram_ttl", "namespace", "test"))
267267

268268
}
269-
func TestDisableObjectSizeLinearHistogram(t *testing.T) {
269+
func TestDisableObjectSizeLinearHistogramIntegration(t *testing.T) {
270270
if testing.Short() {
271271
t.Skip("Skipping aerospike integration tests.")
272272
}
@@ -286,7 +286,7 @@ func TestDisableObjectSizeLinearHistogram(t *testing.T) {
286286

287287
assert.False(t, acc.HasMeasurement("aerospike_histogram_object_size_linear"))
288288
}
289-
func TestObjectSizeLinearHistogram(t *testing.T) {
289+
func TestObjectSizeLinearHistogramIntegration(t *testing.T) {
290290

291291
if testing.Short() {
292292
t.Skip("Skipping aerospike integration tests.")

plugins/inputs/disque/disque_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/stretchr/testify/require"
1111
)
1212

13-
func TestDisqueGeneratesMetrics(t *testing.T) {
13+
func TestDisqueGeneratesMetricsIntegration(t *testing.T) {
1414
if testing.Short() {
1515
t.Skip("Skipping integration test in short mode")
1616
}
@@ -76,7 +76,7 @@ func TestDisqueGeneratesMetrics(t *testing.T) {
7676
acc.AssertContainsFields(t, "disque", fields)
7777
}
7878

79-
func TestDisqueCanPullStatsFromMultipleServers(t *testing.T) {
79+
func TestDisqueCanPullStatsFromMultipleServersIntegration(t *testing.T) {
8080
if testing.Short() {
8181
t.Skip("Skipping integration test in short mode")
8282
}

plugins/inputs/dns_query/dns_query_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ func TestGatheringRootDomain(t *testing.T) {
6767
"server": "8.8.8.8",
6868
"domain": ".",
6969
"record_type": "MX",
70+
"rcode": "NOERROR",
71+
"result": "success",
72+
}
73+
fields := map[string]interface{}{
74+
"rcode_value": int(0),
75+
"result_code": uint64(0),
7076
}
71-
fields := map[string]interface{}{}
7277

7378
err := acc.GatherError(dnsConfig.Gather)
7479
assert.NoError(t, err)
@@ -93,8 +98,13 @@ func TestMetricContainsServerAndDomainAndRecordTypeTags(t *testing.T) {
9398
"server": "8.8.8.8",
9499
"domain": "google.com",
95100
"record_type": "NS",
101+
"rcode": "NOERROR",
102+
"result": "success",
103+
}
104+
fields := map[string]interface{}{
105+
"rcode_value": int(0),
106+
"result_code": uint64(0),
96107
}
97-
fields := map[string]interface{}{}
98108

99109
err := acc.GatherError(dnsConfig.Gather)
100110
assert.NoError(t, err)

plugins/inputs/dovecot/dovecot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/stretchr/testify/require"
1010
)
1111

12-
func TestDovecot(t *testing.T) {
12+
func TestDovecotIntegration(t *testing.T) {
1313

1414
if testing.Short() {
1515
t.Skip("Skipping integration test in short mode")

plugins/inputs/mcrouter/mcrouter_test.go

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestAddressParsing(t *testing.T) {
4444
}
4545
}
4646

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

61-
intMetrics := []string{"uptime", "num_servers", "num_servers_new", "num_servers_up",
62-
"num_servers_down", "num_servers_closed", "num_clients",
63-
"num_suspect_servers", "destination_batches_sum", "destination_requests_sum",
64-
"outstanding_route_get_reqs_queued", "outstanding_route_update_reqs_queued",
65-
"outstanding_route_get_avg_queue_size", "outstanding_route_update_avg_queue_size",
66-
"outstanding_route_get_avg_wait_time_sec", "outstanding_route_update_avg_wait_time_sec",
67-
"retrans_closed_connections", "destination_pending_reqs", "destination_inflight_reqs",
68-
"destination_batch_size", "asynclog_requests", "proxy_reqs_processing",
69-
"proxy_reqs_waiting", "client_queue_notify_period",
70-
"ps_num_minor_faults", "ps_num_major_faults",
71-
"ps_vsize", "ps_rss", "fibers_allocated", "fibers_pool_size", "fibers_stack_high_watermark",
72-
"successful_client_connections", "duration_us", "destination_max_pending_reqs",
73-
"destination_max_inflight_reqs", "retrans_per_kbyte_max", "cmd_get_count", "cmd_delete_out",
74-
"cmd_lease_get", "cmd_set", "cmd_get_out_all", "cmd_get_out", "cmd_lease_set_count",
75-
"cmd_other_out_all", "cmd_lease_get_out", "cmd_set_count", "cmd_lease_set_out",
76-
"cmd_delete_count", "cmd_other", "cmd_delete", "cmd_get", "cmd_lease_set", "cmd_set_out",
77-
"cmd_lease_get_count", "cmd_other_out", "cmd_lease_get_out_all", "cmd_set_out_all",
78-
"cmd_other_count", "cmd_delete_out_all", "cmd_lease_set_out_all"}
79-
80-
floatMetrics := []string{"rusage_system", "rusage_user", "ps_user_time_sec", "ps_system_time_sec"}
61+
intMetrics := []string{
62+
"uptime",
63+
// "num_servers",
64+
// "num_servers_new",
65+
// "num_servers_up",
66+
// "num_servers_down",
67+
// "num_servers_closed",
68+
// "num_clients",
69+
// "num_suspect_servers",
70+
// "destination_batches_sum",
71+
// "destination_requests_sum",
72+
// "outstanding_route_get_reqs_queued",
73+
// "outstanding_route_update_reqs_queued",
74+
// "outstanding_route_get_avg_queue_size",
75+
// "outstanding_route_update_avg_queue_size",
76+
// "outstanding_route_get_avg_wait_time_sec",
77+
// "outstanding_route_update_avg_wait_time_sec",
78+
// "retrans_closed_connections",
79+
// "destination_pending_reqs",
80+
// "destination_inflight_reqs",
81+
// "destination_batch_size",
82+
// "asynclog_requests",
83+
// "proxy_reqs_processing",
84+
// "proxy_reqs_waiting",
85+
// "client_queue_notify_period",
86+
// "ps_num_minor_faults",
87+
// "ps_num_major_faults",
88+
// "ps_vsize",
89+
// "ps_rss",
90+
// "fibers_allocated",
91+
// "fibers_pool_size",
92+
// "fibers_stack_high_watermark",
93+
// "successful_client_connections",
94+
// "duration_us",
95+
// "destination_max_pending_reqs",
96+
// "destination_max_inflight_reqs",
97+
// "retrans_per_kbyte_max",
98+
// "cmd_get_count",
99+
// "cmd_delete_out",
100+
// "cmd_lease_get",
101+
"cmd_set",
102+
// "cmd_get_out_all",
103+
// "cmd_get_out",
104+
// "cmd_lease_set_count",
105+
// "cmd_other_out_all",
106+
// "cmd_lease_get_out",
107+
// "cmd_set_count",
108+
// "cmd_lease_set_out",
109+
// "cmd_delete_count",
110+
// "cmd_other",
111+
// "cmd_delete",
112+
"cmd_get",
113+
// "cmd_lease_set",
114+
// "cmd_set_out",
115+
// "cmd_lease_get_count",
116+
// "cmd_other_out",
117+
// "cmd_lease_get_out_all",
118+
// "cmd_set_out_all",
119+
// "cmd_other_count",
120+
// "cmd_delete_out_all",
121+
// "cmd_lease_set_out_all"
122+
}
123+
124+
floatMetrics := []string{
125+
"rusage_system",
126+
"rusage_user",
127+
// "ps_user_time_sec",
128+
// "ps_system_time_sec",
129+
}
81130

82131
for _, metric := range intMetrics {
83132
assert.True(t, acc.HasInt64Field("mcrouter", metric), metric)

plugins/inputs/memcached/memcached_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/stretchr/testify/require"
1111
)
1212

13-
func TestMemcachedGeneratesMetrics(t *testing.T) {
13+
func TestMemcachedGeneratesMetricsIntegration(t *testing.T) {
1414
if testing.Short() {
1515
t.Skip("Skipping integration test in short mode")
1616
}

0 commit comments

Comments
 (0)