Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/extended/cluster/cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
// This is too familiar, create pods
for _, pod := range p.Pods {
// Parse Pod file into struct
config := ParsePods(mkPath(pod.File))
config, err := ParsePods(mkPath(pod.File))
o.Expect(err).NotTo(o.HaveOccurred())
// Check if environment variables are defined in CL config
if pod.Parameters == nil {
e2e.Logf("Pod environment variables will not be modified.")
Expand All @@ -157,7 +158,7 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
}
// TODO sjug: pass label via config
labels := map[string]string{"purpose": "test"}
err := CreatePods(c, pod.Basename, nsName, labels, config.Spec, pod.Number, tuning, &pod.Sync)
err = CreatePods(c, pod.Basename, nsName, labels, config.Spec, pod.Number, tuning, &pod.Sync)
o.Expect(err).NotTo(o.HaveOccurred())
}
}
Expand Down
31 changes: 22 additions & 9 deletions test/extended/cluster/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"net"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"unicode"

"github.com/ghodss/yaml"
kapiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -26,20 +28,31 @@ import (
// The number of times we re-try to create a pod
const maxRetries = 4

// ParsePods unmarshalls the json file defined in the CL config into a struct
func ParsePods(jsonFile string) (configStruct kapiv1.Pod) {
configFile, err := ioutil.ReadFile(jsonFile)
// ParsePods unmarshalls the pod spec file defined in the CL config into a struct
func ParsePods(file string) (kapiv1.Pod, error) {
var configStruct kapiv1.Pod

configFile, err := ioutil.ReadFile(file)
if err != nil {
framework.Failf("Cant read pod config file. Error: %v", err)
return configStruct, err
}

err = json.Unmarshal(configFile, &configStruct)
if err != nil {
e2e.Failf("Unable to unmarshal pod config. Error: %v", err)
switch filepath.Ext(file) {
case ".yaml", ".yml":
err = yaml.Unmarshal(configFile, &configStruct)
if err != nil {
return configStruct, err
}
case ".json":
err = json.Unmarshal(configFile, &configStruct)
if err != nil {
return configStruct, err
}
default:
return configStruct, fmt.Errorf("Unknown config file extension")
}

e2e.Logf("The loaded config file is: %+v", configStruct.Spec.Containers)
return
return configStruct, nil
}

// SyncPods waits for pods to enter a state
Expand Down