Skip to content

Commit

Permalink
Use atleast 16 nodes for perf test cluster (knative#623)
Browse files Browse the repository at this point in the history
* Use atleast 16 nodes for perf test cluster

* Add quotes to numbers when adding as env var

* Remove unnecessary if condition
  • Loading branch information
srinivashegde86 authored and knative-prow-robot committed Mar 25, 2019
1 parent a26c88e commit 6309304
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ci/prow/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,10 @@ periodics:
mountPath: /etc/test-account
readOnly: true
env:
- name: E2E_MIN_CLUSTER_NODES
value: "16"
- name: E2E_MAX_CLUSTER_NODES
value: "16"
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /etc/test-account/service-account.json
- name: E2E_CLUSTER_REGION
Expand Down
16 changes: 15 additions & 1 deletion ci/prow/make_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ func createCommand(data baseProwJobTemplateData) []string {

// addEnvToJob adds the given key/pair environment variable to the job.
func addEnvToJob(data *baseProwJobTemplateData, key, value string) {
// Value should always be string. Add quotes if we get a number
if isNum(value) {
value = "\"" + value + "\""
}

(*data).Env = append((*data).Env, []string{"- name: " + key, " value: " + value}...)
}

Expand Down Expand Up @@ -847,6 +852,9 @@ func generatePeriodic(title string, repoName string, periodicConfig yaml.MapSlic
jobType = getString(item.Key)
jobNameSuffix = "performance"
data.Base.Command = performanceScript
// We need a larger cluster of at least 16 nodes for perf tests
addEnvToJob(&data.Base, "E2E_MIN_CLUSTER_NODES", "16")
addEnvToJob(&data.Base, "E2E_MAX_CLUSTER_NODES", "16")
case "latency":
if !getBool(item.Value) {
return
Expand Down Expand Up @@ -1044,9 +1052,15 @@ func gitHubRepo(data baseProwJobTemplateData) string {
return s
}

// isNum checks if the given string is a valid number
func isNum(s string) bool {
_, err := strconv.ParseFloat(s, 64)
return err == nil
}

// quote returns the given string quoted if it's not a number, or not a key/value pair, or already quoted.
func quote(s string) string {
if _, err := strconv.ParseFloat(s, 64); err == nil {
if isNum(s) {
return s
}
if strings.Contains(s, "\"") || strings.Contains(s, ": ") || strings.HasSuffix(s, ":") {
Expand Down

0 comments on commit 6309304

Please sign in to comment.