Skip to content

Commit

Permalink
[8.12](backport #37677) [AWS] Ignore @tmp directories in test (#37779)
Browse files Browse the repository at this point in the history
* Ignore @tmp directories in test (#37677)

(cherry picked from commit c23411a)

# Conflicts:
#	pytest.ini
#	x-pack/metricbeat/Jenkinsfile.yml

* Update Jenkinsfile.yml

* Update pytest.ini

---------

Co-authored-by: kaiyan-sheng <kaiyan.sheng@elastic.co>
  • Loading branch information
mergify[bot] and kaiyan-sheng authored Jan 29, 2024
1 parent 374c05d commit 343847a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
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

0 comments on commit 343847a

Please sign in to comment.