Skip to content

Commit

Permalink
Ignore @tmp directories in test (#37677)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyan-sheng authored Jan 22, 2024
1 parent ca03640 commit c23411a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 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 @@ -17,3 +17,4 @@ filterwarnings =
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:HTTPResponse.getheaders\(\) is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.:DeprecationWarning
ignore:The 'warn' method is deprecated, use 'warning' instead:DeprecationWarning
25 changes: 12 additions & 13 deletions x-pack/metricbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ stages:
mage: "mage pythonIntegTest"
withModule: true
stage: mandatory
# Skip test until fixed https://github.com/elastic/beats/issues/37498
#cloud:
# cloud: "mage build test"
# withModule: true ## run the ITs only if the changeset affects a specific module.
# dirs: ## run the cloud tests for the given modules.
# - "x-pack/metricbeat/module/aws"
# when: ## Override the top-level when.
# parameters:
# - "awsCloudTests"
# comments:
# - "/test x-pack/metricbeat for aws cloud"
# labels:
# - "aws"
cloud:
cloud: "mage build test"
withModule: true ## run the ITs only if the changeset affects a specific module.
dirs: ## run the cloud tests for the given modules.
- "x-pack/metricbeat/module/aws"
when: ## Override the top-level when.
parameters:
- "awsCloudTests"
comments:
- "/test x-pack/metricbeat for aws cloud"
labels:
- "aws"
# stage: extended
# Skip test until fixed https://github.com/elastic/beats/issues/36425
#cloudAWS:
Expand Down

0 comments on commit c23411a

Please sign in to comment.