diff --git a/dev-tools/mage/gotest.go b/dev-tools/mage/gotest.go index 5065882fdb8..bc49c3e643c 100644 --- a/dev-tools/mage/gotest.go +++ b/dev-tools/mage/gotest.go @@ -22,7 +22,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "os" "os/exec" @@ -169,15 +168,16 @@ func DefaultTestBinaryArgs() TestBinaryArgs { // Use MODULE=module to run only tests for `module`. func GoTestIntegrationForModule(ctx context.Context) error { module := EnvOr("MODULE", "") - modulesFileInfo, err := ioutil.ReadDir("./module") + modulesFileInfo, err := os.ReadDir("./module") if err != nil { return err } foundModule := false - failedModules := []string{} + failedModules := make([]string, 0, len(modulesFileInfo)) for _, fi := range modulesFileInfo { - if !fi.IsDir() { + // skip the ones that are not directories or with suffix @tmp, which are created by Jenkins build job + if !fi.IsDir() || strings.HasSuffix(fi.Name(), "@tmp") { continue } if module != "" && module != fi.Name() { @@ -289,7 +289,7 @@ func GoTest(ctx context.Context, params GoTestArgs) error { } if params.OutputFile != "" { - fileOutput, err := os.Create(createDir(params.OutputFile)) + fileOutput, err := os.Create(CreateDir(params.OutputFile)) if err != nil { return fmt.Errorf("failed to create go test output file: %w", err) } @@ -356,7 +356,7 @@ func makeCommand(ctx context.Context, env map[string]string, cmd string, args .. for k, v := range env { c.Env = append(c.Env, k+"="+v) } - c.Stdout = ioutil.Discard + c.Stdout = io.Discard if mg.Verbose() { c.Stdout = os.Stdout } diff --git a/libbeat/generator/fields/module_fields_collector.go b/libbeat/generator/fields/module_fields_collector.go index 85f917cacf6..2bf7c7190d4 100644 --- a/libbeat/generator/fields/module_fields_collector.go +++ b/libbeat/generator/fields/module_fields_collector.go @@ -18,9 +18,9 @@ package fields import ( - "io/ioutil" "os" "path/filepath" + "strings" ) var indentByModule = map[string]int{ @@ -38,9 +38,10 @@ func GetModules(modulesDir string) ([]string, error) { return nil, err } - var names []string + names := make([]string, 0, len(moduleInfos)) for _, info := range moduleInfos { - if !info.IsDir() { + // skip the ones that are not directories or with suffix @tmp, which are created by Jenkins build job + if !info.IsDir() || strings.HasSuffix(info.Name(), "@tmp") { continue } names = append(names, info.Name()) @@ -80,7 +81,7 @@ func CollectFiles(module string, modulesPath string) ([]*YmlFile, error) { files = append(files, ymls...) modulesRoot := filepath.Base(modulesPath) - sets, err := ioutil.ReadDir(filepath.Join(modulesPath, module)) + sets, err := os.ReadDir(filepath.Join(modulesPath, module)) if err != nil { return nil, err } diff --git a/pytest.ini b/pytest.ini index 18f364eb795..6c45e46ef83 100644 --- a/pytest.ini +++ b/pytest.ini @@ -16,3 +16,4 @@ filterwarnings = # Ignore distutil Version class deprecation in the compose package until it can be upgraded not to use them. ignore:distutils Version classes are deprecated. Use packaging.version instead.:DeprecationWarning:.*compose.* ignore:distutils Version classes are deprecated. Use packaging.version instead.:DeprecationWarning:.*docker.* + ignore:The 'warn' method is deprecated, use 'warning' instead:DeprecationWarning