Add unit tests to for {runtime,priority}ClassName
These unit tests go over all the possible pods using the
mount feature and make sure they are all listed in the
runtime and priority class, which will make sure we don't
miss any.
Skip-Release-Notes
Change-Id: Iba2e24bebd70f0d99f44566a1b0f115e4faa8f5b
(cherry picked from commit 60bb74c60ea5b503c2348784656f0cb04784e954)
diff --git a/internal/testutils/oslo_db.go b/internal/testutils/oslo_db.go
index b7aabd1..0b02304 100644
--- a/internal/testutils/oslo_db.go
+++ b/internal/testutils/oslo_db.go
@@ -1,6 +1,7 @@
package testutils
import (
+ "strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -13,3 +14,32 @@
assert.Equal(t, 5, config.MaxPoolSize)
assert.Equal(t, -1, config.MaxRetries)
}
+
+func podNameForClass(pod string) string {
+ // There are a few pods which are built/created inside "helm-toolkit" so
+ // we cannot refer to them by their full name or the code will get real
+ // messy.
+ if strings.HasSuffix(pod, "db_init") {
+ return "db_init"
+ } else if strings.HasSuffix(pod, "db_sync") {
+ return "db_sync"
+ } else if strings.HasSuffix(pod, "_bootstrap") {
+ return "bootstrap"
+ }
+
+ return pod
+}
+
+func TestAllPodsHaveRuntimeClass(t *testing.T, vals *openstack_helm.HelmValues) {
+ for pod := range vals.Pod.Mounts {
+ podName := podNameForClass(pod)
+ assert.Contains(t, vals.Pod.RuntimeClass, podName)
+ }
+}
+
+func TestAllPodsHavePriorityClass(t *testing.T, vals *openstack_helm.HelmValues) {
+ for pod := range vals.Pod.Mounts {
+ podName := podNameForClass(pod)
+ assert.Contains(t, vals.Pod.PriorityClass, podName)
+ }
+}