Merge pull request #935 from Lomanic/issue900

[linux] Fix #900, skip or fix failing tests in docker
This commit is contained in:
Lomanic 2020-09-02 10:35:27 +02:00 committed by GitHub
commit e1925b853e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View File

@ -67,7 +67,7 @@ func TestUsers(t *testing.T) {
}
empty := UserStat{}
if len(v) == 0 {
t.Fatal("Users is empty")
t.Skip("Users is empty")
}
for _, u := range v {
if u == empty {

View File

@ -3,6 +3,7 @@ package net
import (
"fmt"
"io/ioutil"
"net"
"os"
"strings"
"syscall"
@ -77,9 +78,27 @@ func TestIOCountersByFileParsing(t *testing.T) {
}
func TestGetProcInodesAll(t *testing.T) {
if os.Getenv("CIRCLECI") == "true" {
t.Skip("Skip CI")
}
waitForServer := make(chan bool)
go func() { // TCP listening goroutine to have some opened inodes even in CI
addr, err := net.ResolveTCPAddr("tcp", "localhost:0") // dynamically get a random open port from OS
if err != nil {
t.Skip("unable to resolve localhost:", err)
}
l, err := net.ListenTCP(addr.Network(), addr)
if err != nil {
t.Skip(fmt.Sprintf("unable to listen on %v: %v", addr, err))
}
defer l.Close()
waitForServer <- true
for {
conn, err := l.Accept()
if err != nil {
t.Skip("unable to accept connection:", err)
}
defer conn.Close()
}
}()
<-waitForServer
root := common.HostProc("")
v, err := getProcInodesAll(root, 0)
@ -88,7 +107,7 @@ func TestGetProcInodesAll(t *testing.T) {
}
func TestConnectionsMax(t *testing.T) {
if os.Getenv("CIRCLECI") == "true" {
if os.Getenv("CI") != "" {
t.Skip("Skip CI")
}

View File

@ -253,7 +253,10 @@ func Test_Process_Groups(t *testing.T) {
if err != nil {
t.Errorf("getting groups error %v", err)
}
if len(v) <= 0 || v[0] < 0 {
if len(v) == 0 {
t.Skip("Groups is empty")
}
if v[0] < 0 {
t.Errorf("invalid Groups: %v", v)
}
}