Skip to content

Commit

Permalink
Fixing flaky tests for windows 7 32bit (#23480)
Browse files Browse the repository at this point in the history
* enabling testing on windows 32 bit

* update test file

* fix

* [CI] Optional stage instead the mandatory one

windows stage is mandatory, but optional stages are not mandatory for PRs

* fix int issue

* ignore 386 architecture

* skip tests

* skip test

* function redeclared

* re write

* add windows constraint

* add tag

* add comments

Co-authored-by: Victor Martinez <VictorMartinezRubio@gmail.com>
  • Loading branch information
narph and v1v authored Jan 19, 2021
1 parent d041576 commit 1b43637
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 43 deletions.
12 changes: 11 additions & 1 deletion metricbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ stages:
mage: "mage build unitTest"
platforms: ## override default labels in this specific stage.
- "windows-2019"
#- "windows-7-32-bit" https://github.com/elastic/beats/issues/19835
when: ## Override the top-level when.
not_changeset_full_match: "^x-pack/.*" ## Disable the stage if ONLY changes for the x-pack
branches: true ## for all the branches
Expand Down Expand Up @@ -133,3 +132,14 @@ stages:
- "windows-7"
branches: true ## for all the branches
tags: true ## for all the tags
windows-7-32:
mage: "mage build unitTest"
platforms: ## override default labels in this specific stage.
- "windows-7-32-bit"
when: ## Override the top-level when.
comments:
- "/test metricbeat for windows-7-32"
labels:
- "windows-7-32"
branches: true ## for all the branches
tags: true ## for all the tags
4 changes: 2 additions & 2 deletions metricbeat/helper/elastic/elastic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func TestFixTimestampField(t *testing.T) {
{
"converts float64s in scientific notation to ints",
map[string]interface{}{
"foo": 1.571284349e12,
"foo": 1.571284349e+09,
},
map[string]interface{}{
"foo": 1571284349000,
"foo": 1571284349,
},
},
{
Expand Down
3 changes: 3 additions & 0 deletions metricbeat/mb/testing/data/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.

// skipping tests on windows 32 bit versions, not supported
// +build !windows,!386

package data

import (
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/ceph/cluster_status/cluster_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func TestFetchEventContents(t *testing.T) {
//check pg info
pgInfo := event["pg"].(common.MapStr)
assert.EqualValues(t, 1054023794, pgInfo["data_bytes"])
assert.EqualValues(t, 9965821952, pgInfo["avail_bytes"])
assert.EqualValues(t, 12838682624, pgInfo["total_bytes"])
assert.EqualValues(t, 2872860672, pgInfo["used_bytes"])
assert.EqualValues(t, int64(9965821952), pgInfo["avail_bytes"])
assert.EqualValues(t, int64(12838682624), pgInfo["total_bytes"])
assert.EqualValues(t, int64(2872860672), pgInfo["used_bytes"])

//check pg_state info
pgStateInfo := events[1].MetricSetFields["pg_state"].(common.MapStr)
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/etcd/metrics/_meta/testdata/metrics.plain
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ etcd_disk_backend_snapshot_duration_seconds_sum 0
etcd_disk_backend_snapshot_duration_seconds_count 0
# HELP etcd_disk_wal_fsync_duration_seconds The latency distributions of fsync called by wal.
# TYPE etcd_disk_wal_fsync_duration_seconds histogram
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.001"} 0
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.002"} 0
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.004"} 0
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.001"} 1
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.002"} 1
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.004"} 1
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.008"} 2
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.016"} 2
etcd_disk_wal_fsync_duration_seconds_bucket{le="0.032"} 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"ns": {
"bucket": {
"+Inf": 3,
"1000000": 0,
"1000000": 1,
"1024000000": 3,
"128000000": 3,
"16000000": 2,
"2000000": 0,
"2000000": 1,
"2048000000": 3,
"256000000": 3,
"32000000": 2,
"4000000": 0,
"4000000": 1,
"4096000000": 3,
"512000000": 3,
"64000000": 3,
Expand Down Expand Up @@ -102,4 +102,4 @@
"type": "etcd"
}
}
]
]
2 changes: 1 addition & 1 deletion metricbeat/module/etcd/metrics/metrics_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestFetch(t *testing.T) {
t.Logf("%s/%s event: %+v", m.Module().Name(), m.Name(), events[0])
}

func TestData(t *testing.T) {
func TestIntegrationData(t *testing.T) {
service := compose.EnsureUp(t, "etcd")

m := mbtest.NewFetcher(t, getConfig(service.Host()))
Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/etcd/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package metrics

Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/kubernetes/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package apiserver

Expand Down
8 changes: 4 additions & 4 deletions metricbeat/module/kubernetes/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestEventMapping(t *testing.T) {
"cpu.usage.core.ns": 43959424,
"cpu.usage.nanocores": 11263994,

"logs.available.bytes": 98727014400,
"logs.capacity.bytes": 101258067968,
"logs.available.bytes": int64(98727014400),
"logs.capacity.bytes": int64(101258067968),
"logs.used.bytes": 28672,
"logs.inodes.count": 6258720,
"logs.inodes.free": 6120096,
Expand All @@ -75,8 +75,8 @@ func TestEventMapping(t *testing.T) {

"name": "nginx",

"rootfs.available.bytes": 98727014400,
"rootfs.capacity.bytes": 101258067968,
"rootfs.available.bytes": int64(98727014400),
"rootfs.capacity.bytes": int64(101258067968),
"rootfs.used.bytes": 61440,
"rootfs.inodes.used": 21,
}
Expand Down
14 changes: 7 additions & 7 deletions metricbeat/module/kubernetes/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ func TestEventMapping(t *testing.T) {
assert.NoError(t, err, "error mapping "+testFile)

testCases := map[string]interface{}{
"cpu.usage.core.ns": 4189523881380,
"cpu.usage.core.ns": int64(4189523881380),
"cpu.usage.nanocores": 18691146,

"memory.available.bytes": 1768316928,
"memory.usage.bytes": 2764943360,
"memory.usage.bytes": int64(2764943360),
"memory.rss.bytes": 2150400,
"memory.workingset.bytes": 2111090688,
"memory.pagefaults": 131567,
"memory.majorpagefaults": 103,

"name": "gke-beats-default-pool-a5b33e2e-hdww",

"fs.available.bytes": 98727014400,
"fs.capacity.bytes": 101258067968,
"fs.used.bytes": 2514276352,
"fs.available.bytes": int64(98727014400),
"fs.capacity.bytes": int64(101258067968),
"fs.used.bytes": int64(2514276352),
"fs.inodes.used": 138624,
"fs.inodes.free": uint64(18446744073709551615),
"fs.inodes.count": 6258720,
Expand All @@ -66,8 +66,8 @@ func TestEventMapping(t *testing.T) {
"network.tx.bytes": 812729002,
"network.tx.errors": 0,

"runtime.imagefs.available.bytes": 98727014400,
"runtime.imagefs.capacity.bytes": 101258067968,
"runtime.imagefs.available.bytes": int64(98727014400),
"runtime.imagefs.capacity.bytes": int64(101258067968),
"runtime.imagefs.used.bytes": 860204379,
}

Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/kubernetes/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package proxy

Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/kubernetes/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package scheduler

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/system/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestEventMapping(t *testing.T) {
"memory.pagefaults": 100835242,
"memory.majorpagefaults": 0,

"cpu.usage.core.ns": 2357800908948,
"cpu.usage.core.ns": int64(2357800908948),
"cpu.usage.nanocores": 11263994,
}

Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/rabbitmq/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func testFetch(t *testing.T, collect string) {

disk := event["disk"].(common.MapStr)
free := disk["free"].(common.MapStr)
assert.EqualValues(t, 98317942784, free["bytes"])
assert.EqualValues(t, int64(98317942784), free["bytes"])

limit := free["limit"].(common.MapStr)
assert.EqualValues(t, 50000000, limit["bytes"])
Expand All @@ -73,7 +73,7 @@ func testFetch(t *testing.T, collect string) {
num := gc["num"].(common.MapStr)
assert.EqualValues(t, 1049055, num["count"])
reclaimed := gc["reclaimed"].(common.MapStr)
assert.EqualValues(t, 27352751800, reclaimed["bytes"])
assert.EqualValues(t, int64(27352751800), reclaimed["bytes"])

io := event["io"].(common.MapStr)
fileHandle := io["file_handle"].(common.MapStr)
Expand Down Expand Up @@ -109,7 +109,7 @@ func testFetch(t *testing.T, collect string) {

mem := event["mem"].(common.MapStr)
limit = mem["limit"].(common.MapStr)
assert.EqualValues(t, 6628692787, limit["bytes"])
assert.EqualValues(t, int64(6628692787), limit["bytes"])
used := mem["used"].(common.MapStr)
assert.EqualValues(t, 105504768, used["bytes"])

Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def test_socket_summary(self):

assert isinstance(udp["all"]["count"], int)

@unittest.skipIf(sys.platform == "win32", "Flaky test")
def check_username(self, observed, expected=None):
if expected is None:
expected = getpass.getuser()
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/vsphere/host/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func TestEventMapping(t *testing.T) {
assert.EqualValues(t, 4521, cpuFree)

memoryUsed, _ := event.GetValue("memory.used.bytes")
assert.EqualValues(t, 2251799812636672, memoryUsed)
assert.EqualValues(t, int64(2251799812636672), memoryUsed)

memoryTotal, _ := event.GetValue("memory.total.bytes")
assert.EqualValues(t, 2251799812636672, memoryTotal)
assert.EqualValues(t, int64(2251799812636672), memoryTotal)

memoryFree, _ := event.GetValue("memory.free.bytes")
assert.EqualValues(t, 0, memoryFree)
Expand Down
12 changes: 11 additions & 1 deletion x-pack/metricbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ stages:
mage: "mage build unitTest"
platforms: ## override default labels in this specific stage.
- "windows-2019"
#- "windows-7-32-bit" https://github.com/elastic/beats/issues/19835
windows-2016:
mage: "mage build unitTest"
platforms: ## override default labels in this specific stage.
Expand Down Expand Up @@ -116,3 +115,14 @@ stages:
- "windows-7"
branches: true ## for all the branches
tags: true ## for all the tags
windows-7-32:
mage: "mage build unitTest"
platforms: ## override default labels in this specific stage.
- "windows-7-32-bit"
when: ## Override the top-level when.
comments:
- "/test x-pack/metricbeat for windows-7-32"
labels:
- "windows-7-32"
branches: true ## for all the branches
tags: true ## for all the tags
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/cockroachdb/status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package status

Expand Down
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/coredns/stats/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package stats

Expand Down
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/istio/citadel/citadel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package citadel

Expand Down
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/istio/galley/galley_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package galley

Expand Down
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/istio/mesh/mesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package mesh

Expand Down
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/istio/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package proxy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

// +build !integration
// skipping tests on windows 32 bit versions, not supported
// +build !integration,!windows,!386

package collector

Expand Down

0 comments on commit 1b43637

Please sign in to comment.