This is an automated email from the ASF dual-hosted git repository.
wilfreds pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new b331cb68 [YUNIKORN-2168] Generate better random data (#728)
b331cb68 is described below
commit b331cb68a89f59635bd3215be2baa5696b033f7b
Author: Kuan-Po Tseng <[email protected]>
AuthorDate: Tue Nov 28 12:28:06 2023 +1100
[YUNIKORN-2168] Generate better random data (#728)
In queue_test.go and template_test.go replace the seconds based resource
sizing with random values from math random.
Add nolint remarks to all lines that use the random since it is not a
security related random.
Closes: #728
Signed-off-by: Wilfred Spiegelenburg <[email protected]>
---
pkg/scheduler/objects/queue_test.go | 5 +++--
pkg/scheduler/objects/template/template_test.go | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/pkg/scheduler/objects/queue_test.go
b/pkg/scheduler/objects/queue_test.go
index b0d32b65..5d390db3 100644
--- a/pkg/scheduler/objects/queue_test.go
+++ b/pkg/scheduler/objects/queue_test.go
@@ -20,6 +20,7 @@ package objects
import (
"fmt"
+ "math/rand"
"reflect"
"sort"
"strconv"
@@ -1728,7 +1729,7 @@ func getAllocatingAcceptedApps() map[string]bool {
func getResourceConf() map[string]string {
resource := make(map[string]string)
- resource["memory"] = strconv.Itoa(time.Now().Second()%1000 + 100)
+ resource["memory"] = strconv.Itoa(rand.Intn(10000) + 100) //nolint:gosec
return resource
}
@@ -1747,7 +1748,7 @@ func getZeroResourceConf() map[string]string {
func getProperties() map[string]string {
properties := make(map[string]string)
- properties[strconv.Itoa(time.Now().Second())] =
strconv.Itoa(time.Now().Second())
+ properties[strconv.Itoa(rand.Intn(10000))] =
strconv.Itoa(rand.Intn(10000)) //nolint:gosec
return properties
}
diff --git a/pkg/scheduler/objects/template/template_test.go
b/pkg/scheduler/objects/template/template_test.go
index 138ca737..cbe78078 100644
--- a/pkg/scheduler/objects/template/template_test.go
+++ b/pkg/scheduler/objects/template/template_test.go
@@ -19,9 +19,9 @@
package template
import (
+ "math/rand"
"strconv"
"testing"
- "time"
"gotest.tools/v3/assert"
@@ -31,14 +31,14 @@ import (
func getResourceConf() map[string]string {
resource := make(map[string]string)
- resource["memory"] = strconv.Itoa(time.Now().Second()%1000 + 10)
- resource["vcore"] = strconv.Itoa(time.Now().Second()%1000 + 10)
+ resource["memory"] = strconv.Itoa(rand.Intn(10000) + 10) //nolint:gosec
+ resource["vcore"] = strconv.Itoa(rand.Intn(10000) + 10) //nolint:gosec
return resource
}
func getProperties() map[string]string {
properties := make(map[string]string)
- properties[strconv.Itoa(time.Now().Second()%1000)] =
strconv.Itoa(time.Now().Second() % 1000)
+ properties[strconv.Itoa(rand.Intn(10000))] =
strconv.Itoa(rand.Intn(10000)) //nolint:gosec
return properties
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]