Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.12](backport #37677) [AWS] Ignore @tmp directories in test #37779

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 5 additions & 4 deletions libbeat/generator/fields/module_fields_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package fields

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
)

var indentByModule = map[string]int{
Expand All @@ -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())
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading