Merge "Add unit tests to for {runtime,priority}ClassName" into stable/2023.2
diff --git a/internal/openstack_helm/ironic.go b/internal/openstack_helm/ironic.go
new file mode 100644
index 0000000..ff19502
--- /dev/null
+++ b/internal/openstack_helm/ironic.go
@@ -0,0 +1,5 @@
+package openstack_helm
+
+type IronicConf struct {
+ Database *DatabaseConf `yaml:"database,omitempty"`
+}
diff --git a/internal/openstack_helm/memcached.go b/internal/openstack_helm/memcached.go
new file mode 100644
index 0000000..0051a08
--- /dev/null
+++ b/internal/openstack_helm/memcached.go
@@ -0,0 +1,5 @@
+package openstack_helm
+
+type MemcachedConf struct {
+ Database *DatabaseConf `yaml:"database,omitempty"`
+}
diff --git a/internal/openstack_helm/openstack_helm.go b/internal/openstack_helm/openstack_helm.go
index 5280e16..c8dd65e 100644
--- a/internal/openstack_helm/openstack_helm.go
+++ b/internal/openstack_helm/openstack_helm.go
@@ -7,18 +7,32 @@
)
type HelmValues struct {
+ Pod `yaml:"pod"`
Conf `yaml:"conf"`
}
+type PodPriorityClassConfig map[string]string
+type PodRuntimeClassConfig map[string]string
+
+type PodMount map[string]interface{}
+
+type Pod struct {
+ PriorityClass PodPriorityClassConfig `yaml:"priorityClassName,omitempty"`
+ RuntimeClass PodRuntimeClassConfig `yaml:"runtimeClassName,omitempty"`
+ Mounts map[string]PodMount `yaml:"mounts,omitempty"`
+}
+
type Conf struct {
Barbican *BarbicanConf `yaml:"barbican,omitempty"`
Cinder *CinderConf `yaml:"cinder,omitempty"`
Designate *DesignateConf `yaml:"designate,omitempty"`
Glance *GlanceConf `yaml:"glance,omitempty"`
Heat *HeatConf `yaml:"heat,omitempty"`
+ Ironic *IronicConf `yaml:"ironic,omitempty"`
Keystone *KeystoneConf `yaml:"keystone,omitempty"`
Magnum *MagnumConf `yaml:"magnum,omitempty"`
Manila *ManilaConf `yaml:"manila,omitempty"`
+ Memcached *MemcachedConf `yaml:"memcached,omitempty"`
Neutron *NeutronConf `yaml:"neutron,omitempty"`
Nova *NovaConf `yaml:"nova,omitempty"`
Octavia *OctaviaConf `yaml:"octavia,omitempty"`
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)
+ }
+}
diff --git a/roles/barbican/vars_test.go b/roles/barbican/vars_test.go
index 8a0dccc..ca6a897 100644
--- a/roles/barbican/vars_test.go
+++ b/roles/barbican/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Barbican.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/cinder/vars_test.go b/roles/cinder/vars_test.go
index c501802..c2ba7d3 100644
--- a/roles/cinder/vars_test.go
+++ b/roles/cinder/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Cinder.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/designate/vars_test.go b/roles/designate/vars_test.go
index e3ec382..36be484 100644
--- a/roles/designate/vars_test.go
+++ b/roles/designate/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Designate.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/glance/vars_test.go b/roles/glance/vars_test.go
index aa0455c..9b95a4c 100644
--- a/roles/glance/vars_test.go
+++ b/roles/glance/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Glance.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/heat/vars_test.go b/roles/heat/vars_test.go
index a87f90c..be07332 100644
--- a/roles/heat/vars_test.go
+++ b/roles/heat/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Heat.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/horizon/vars_test.go b/roles/horizon/vars_test.go
new file mode 100644
index 0000000..0799720
--- /dev/null
+++ b/roles/horizon/vars_test.go
@@ -0,0 +1,40 @@
+package horizon
+
+import (
+ _ "embed"
+ "os"
+ "testing"
+
+ "github.com/goccy/go-yaml"
+ "github.com/stretchr/testify/require"
+
+ "github.com/vexxhost/atmosphere/internal/openstack_helm"
+ "github.com/vexxhost/atmosphere/internal/testutils"
+)
+
+var (
+ //go:embed vars/main.yml
+ varsFile []byte
+ vars Vars
+)
+
+type Vars struct {
+ openstack_helm.HelmValues `yaml:"_horizon_helm_values"`
+}
+
+func TestMain(m *testing.M) {
+ t := &testing.T{}
+ err := yaml.UnmarshalWithOptions(varsFile, &vars)
+ require.NoError(t, err)
+
+ code := m.Run()
+ os.Exit(code)
+}
+
+func TestHelmValues(t *testing.T) {
+ vals, err := openstack_helm.CoalescedHelmValues("../../charts/horizon", &vars.HelmValues)
+ require.NoError(t, err)
+
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
+}
diff --git a/roles/ironic/vars/main.yml b/roles/ironic/vars/main.yml
index 7543920..df71b6e 100644
--- a/roles/ironic/vars/main.yml
+++ b/roles/ironic/vars/main.yml
@@ -51,6 +51,11 @@
clean_step_priority_override: deploy.erase_devices_express:5
deploy_kernel: "{{ ironic_python_agent_deploy_kernel.images.0.id }}"
deploy_ramdisk: "{{ ironic_python_agent_deploy_ramdisk.images.0.id }}"
+ database:
+ connection_recycle_time: 600
+ max_overflow: 50
+ max_pool_size: 5
+ pool_timeout: 30
deploy:
erase_devices_priority: 0
erase_devices_metadata_priority: 0
diff --git a/roles/ironic/vars_test.go b/roles/ironic/vars_test.go
new file mode 100644
index 0000000..658e211
--- /dev/null
+++ b/roles/ironic/vars_test.go
@@ -0,0 +1,41 @@
+package ironic
+
+import (
+ _ "embed"
+ "os"
+ "testing"
+
+ "github.com/goccy/go-yaml"
+ "github.com/stretchr/testify/require"
+
+ "github.com/vexxhost/atmosphere/internal/openstack_helm"
+ "github.com/vexxhost/atmosphere/internal/testutils"
+)
+
+var (
+ //go:embed vars/main.yml
+ varsFile []byte
+ vars Vars
+)
+
+type Vars struct {
+ openstack_helm.HelmValues `yaml:"_ironic_helm_values"`
+}
+
+func TestMain(m *testing.M) {
+ t := &testing.T{}
+ err := yaml.UnmarshalWithOptions(varsFile, &vars)
+ require.NoError(t, err)
+
+ code := m.Run()
+ os.Exit(code)
+}
+
+func TestHelmValues(t *testing.T) {
+ vals, err := openstack_helm.CoalescedHelmValues("../../charts/ironic", &vars.HelmValues)
+ require.NoError(t, err)
+
+ testutils.TestDatabaseConf(t, vals.Conf.Ironic.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
+}
diff --git a/roles/keystone/vars_test.go b/roles/keystone/vars_test.go
index c5bfe19..f79886a 100644
--- a/roles/keystone/vars_test.go
+++ b/roles/keystone/vars_test.go
@@ -29,4 +29,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Keystone.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/magnum/vars_test.go b/roles/magnum/vars_test.go
index 21e8fd6..c727b6c 100644
--- a/roles/magnum/vars_test.go
+++ b/roles/magnum/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Magnum.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/manila/vars_test.go b/roles/manila/vars_test.go
index 627920b..14f578f 100644
--- a/roles/manila/vars_test.go
+++ b/roles/manila/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Manila.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/memcached/vars_test.go b/roles/memcached/vars_test.go
new file mode 100644
index 0000000..81062ef
--- /dev/null
+++ b/roles/memcached/vars_test.go
@@ -0,0 +1,40 @@
+package memcached
+
+import (
+ _ "embed"
+ "os"
+ "testing"
+
+ "github.com/goccy/go-yaml"
+ "github.com/stretchr/testify/require"
+
+ "github.com/vexxhost/atmosphere/internal/openstack_helm"
+ "github.com/vexxhost/atmosphere/internal/testutils"
+)
+
+var (
+ //go:embed vars/main.yml
+ varsFile []byte
+ vars Vars
+)
+
+type Vars struct {
+ openstack_helm.HelmValues `yaml:"_memcached_helm_values"`
+}
+
+func TestMain(m *testing.M) {
+ t := &testing.T{}
+ err := yaml.UnmarshalWithOptions(varsFile, &vars)
+ require.NoError(t, err)
+
+ code := m.Run()
+ os.Exit(code)
+}
+
+func TestHelmValues(t *testing.T) {
+ vals, err := openstack_helm.CoalescedHelmValues("../../charts/memcached", &vars.HelmValues)
+ require.NoError(t, err)
+
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
+}
diff --git a/roles/neutron/vars_test.go b/roles/neutron/vars_test.go
index 8358366..1ce11e2 100644
--- a/roles/neutron/vars_test.go
+++ b/roles/neutron/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Neutron.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/nova/vars_test.go b/roles/nova/vars_test.go
index 716b946..93046f8 100644
--- a/roles/nova/vars_test.go
+++ b/roles/nova/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Nova.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/octavia/vars_test.go b/roles/octavia/vars_test.go
index 8c99a14..4e7068e 100644
--- a/roles/octavia/vars_test.go
+++ b/roles/octavia/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Octavia.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/placement/vars_test.go b/roles/placement/vars_test.go
index fa3fac3..f0cb72f 100644
--- a/roles/placement/vars_test.go
+++ b/roles/placement/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Placement.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}
diff --git a/roles/staffeln/vars_test.go b/roles/staffeln/vars_test.go
index 07ec9ab..9377c01 100644
--- a/roles/staffeln/vars_test.go
+++ b/roles/staffeln/vars_test.go
@@ -36,4 +36,6 @@
require.NoError(t, err)
testutils.TestDatabaseConf(t, vals.Conf.Staffeln.Database)
+ testutils.TestAllPodsHaveRuntimeClass(t, vals)
+ testutils.TestAllPodsHavePriorityClass(t, vals)
}