mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
Due to inconsistent truncation of RBAC names, it's not possible to deploy an autoscaling RayService with a long name. This PR fixes that issue. Closes #643. Signed-off-by: Dmitri Gekhtman <[email protected]>
31 lines
627 B
Go
31 lines
627 B
Go
package common
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/ray-project/kuberay/ray-operator/controllers/ray/utils"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Generate a string of length 200.
|
|
func longString(t *testing.T) string {
|
|
var b bytes.Buffer
|
|
for i := 0; i < 200; i++ {
|
|
b.WriteString("a")
|
|
}
|
|
result := b.String()
|
|
// Confirm length.
|
|
assert.Equal(t, len(result), 200)
|
|
return result
|
|
}
|
|
|
|
// Clip the above string using utils.CheckName
|
|
// to a string of length 50.
|
|
func shortString(t *testing.T) string {
|
|
result := utils.CheckName(longString(t))
|
|
// Confirm length.
|
|
assert.Equal(t, len(result), 50)
|
|
return result
|
|
}
|