Skip to content

Commit

Permalink
chore: move command to integtest package
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Jun 10, 2021
1 parent 5d6459a commit e5265a6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 68 deletions.
32 changes: 32 additions & 0 deletions dev-tools/mage/target/integtest/integtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ package integtest

import (
"context"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/magefile/mage/mg"

Expand Down Expand Up @@ -89,3 +93,31 @@ func PythonIntegTest(ctx context.Context) error {
return devtools.PythonTest(devtools.DefaultPythonTestIntegrationArgs())
})
}

// PackageSystemTests packages the python system tests results
func PackageSystemTests() error {
excludeds := []string{".ci", ".git", ".github", "vendor", "dev-tools"}

// include run as it's the directory we want to compress
systemTestsDir := fmt.Sprintf("build%[1]csystem-tests%[1]crun", os.PathSeparator)
files, err := devtools.FindFilesRecursive(func(path string, _ os.FileInfo) bool {
base := filepath.Base(path)
for _, excluded := range excludeds {
if strings.HasPrefix(base, excluded) {
return false
}
}

return strings.HasPrefix(path, systemTestsDir)
})
if err != nil {
return err
}

if len(files) == 0 {
fmt.Printf(">> there are no system test files under %s", systemTestsDir)
return nil
}

return devtools.Tar(systemTestsDir, devtools.MustExpand("{{ elastic_beats_dir }}/build/system-tests-"+devtools.MustExpand("{{ repo.SubDir }}")+".tar.gz"))
}
12 changes: 11 additions & 1 deletion dev-tools/mage/target/integtest/notests/integtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

package notests

import "fmt"
import (
"fmt"
// mage:import

integtest "github.com/elastic/beats/v7/dev-tools/mage/target/integtest"
)

// IntegTest executes integration tests (it uses Docker to run the tests).
func IntegTest() {
Expand All @@ -28,3 +33,8 @@ func IntegTest() {
func GoIntegTest() {
fmt.Println(">> integTest: Complete (no tests require the integ test environment)")
}

// PackageSystemTests packages the python system tests results
func PackageSystemTests() error {
return integtest.PackageSystemTests()
}
55 changes: 0 additions & 55 deletions dev-tools/mage/target/systemtest/python.go

This file was deleted.

2 changes: 0 additions & 2 deletions filebeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
// mage:import generate
_ "github.com/elastic/beats/v7/filebeat/scripts/mage/generate"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/systemtest"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/test"
Expand Down
2 changes: 0 additions & 2 deletions heartbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/build"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/systemtest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/integtest"
Expand Down
2 changes: 0 additions & 2 deletions metricbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import (
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/pkg"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/systemtest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/test"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
Expand Down
2 changes: 0 additions & 2 deletions x-pack/elastic-agent/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import (
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/integtest/notests"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/systemtest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/test"
)

Expand Down
2 changes: 0 additions & 2 deletions x-pack/filebeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/compose"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/systemtest"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/test"
Expand Down
2 changes: 0 additions & 2 deletions x-pack/metricbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/compose"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/systemtest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/test"
// mage:import
_ "github.com/elastic/beats/v7/metricbeat/scripts/mage/target/metricset"
Expand Down

0 comments on commit e5265a6

Please sign in to comment.