This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 560
/
ginkgo.go
63 lines (57 loc) · 1.62 KB
/
ginkgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package runner
import (
"fmt"
"log"
"os"
"os/exec"
"github.com/Azure/acs-engine/test/e2e/config"
"github.com/Azure/acs-engine/test/e2e/kubernetes/util"
"github.com/Azure/acs-engine/test/e2e/metrics"
"github.com/kelseyhightower/envconfig"
)
// Ginkgo contains all of the information needed to run the ginkgo suite of tests
type Ginkgo struct {
GinkgoNodes string `envconfig:"GINKGO_NODES" default:"6"`
Config *config.Config
Point *metrics.Point
}
// BuildGinkgoRunner creates a new Ginkgo object
func BuildGinkgoRunner(cfg *config.Config, pt *metrics.Point) (*Ginkgo, error) {
g := new(Ginkgo)
if err := envconfig.Process("ginkgo", g); err != nil {
return nil, err
}
g.Config = cfg
g.Point = pt
return g, nil
}
// Run will execute an orchestrator suite of tests
func (g *Ginkgo) Run() error {
g.Point.SetTestStart()
testDir := fmt.Sprintf("test/e2e/%s", g.Config.Orchestrator)
cmd := exec.Command("ginkgo", "-slowSpecThreshold", "180", "-r", "-v", testDir)
util.PrintCommand(cmd)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
g.Point.RecordTestError()
log.Printf("Error while trying to start ginkgo:%s\n", err)
return err
}
err = cmd.Wait()
if err != nil {
g.Point.RecordTestError()
if g.Config.IsKubernetes() || g.Config.IsOpenShift() {
kubectl := exec.Command("kubectl", "get", "all", "--all-namespaces", "-o", "wide")
util.PrintCommand(kubectl)
kubectl.CombinedOutput()
kubectl = exec.Command("kubectl", "get", "nodes", "-o", "wide")
util.PrintCommand(kubectl)
kubectl.CombinedOutput()
}
return err
}
g.Point.RecordTestSuccess()
return nil
}