forked from openshift/osde2e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.go
More file actions
46 lines (38 loc) · 1.25 KB
/
runner.go
File metadata and controls
46 lines (38 loc) · 1.25 KB
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
package helper
import (
"io/ioutil"
"os"
"path/filepath"
. "github.com/onsi/gomega"
"github.com/spf13/viper"
"github.com/openshift/osde2e/pkg/common/config"
"github.com/openshift/osde2e/pkg/common/runner"
)
// RunnerWithNoCommand creates an extended test suite runner and configure RBAC for it.
func (h *H) RunnerWithNoCommand() *runner.Runner {
r := runner.DefaultRunner.DeepCopy()
// setup clients
r.Kube = h.Kube()
r.Image = h.Image()
// setup tests
r.Namespace = h.CurrentProject()
r.PodSpec.ServiceAccountName = h.GetNamespacedServiceAccount()
return r
}
// Runner creates an extended test suite runner and configure RBAC for it and runs cmd in it.
func (h *H) Runner(cmd string) *runner.Runner {
r := h.RunnerWithNoCommand()
r.PodSpec.ServiceAccountName = h.GetNamespacedServiceAccount()
r.Cmd = cmd
return r
}
// WriteResults dumps runner results into the ReportDir.
func (h *H) WriteResults(results map[string][]byte) {
for filename, data := range results {
dst := filepath.Join(viper.GetString(config.ReportDir), viper.GetString(config.Phase), filename)
err := os.MkdirAll(filepath.Dir(dst), os.FileMode(0755))
Expect(err).NotTo(HaveOccurred())
err = ioutil.WriteFile(dst, data, os.ModePerm)
Expect(err).NotTo(HaveOccurred())
}
}