[ATMOSPHERE-536] [stable/2023.2] ci: update go unit tests (#2074)

This is an automated cherry-pick of #1983
/assign okozachenko1203
diff --git a/roles/defaults/vars.go b/roles/defaults/vars.go
index 4c11748..0799e7d 100644
--- a/roles/defaults/vars.go
+++ b/roles/defaults/vars.go
@@ -3,6 +3,7 @@
 import (
 	"bytes"
 	_ "embed"
+	"strings"
 
 	"github.com/goccy/go-yaml"
 )
@@ -12,14 +13,25 @@
 	varsFile []byte
 )
 
+// Define a global variable for the release value.
+var release = "main"
+
+// Function to replace the {{ release }} placeholders
+func replaceReleaseInYAML(yamlContent []byte, release string) []byte {
+	return []byte(strings.ReplaceAll(string(yamlContent), "{{ atmosphere_release }}", release))
+}
+
 func GetImages() (map[string]string, error) {
+	// Replace {{ release }} with the actual release value
+	modifiedVarsFile := replaceReleaseInYAML(varsFile, release)
+
 	path, err := yaml.PathString("$._atmosphere_images")
 	if err != nil {
 		return nil, err
 	}
 
 	var images map[string]string
-	if err := path.Read(bytes.NewReader(varsFile), &images); err != nil {
+	if err := path.Read(bytes.NewReader(modifiedVarsFile), &images); err != nil {
 		return nil, err
 	}
 
diff --git a/roles/defaults/vars_test.go b/roles/defaults/vars_test.go
index 7224a40..44e022d 100644
--- a/roles/defaults/vars_test.go
+++ b/roles/defaults/vars_test.go
@@ -28,16 +28,22 @@
 		// NOTE(mnaser): ParseReference does not allow both tag & digest,
 		//               so we strip the tags from the image name.
 		nameWithTagSplit := strings.Split(image, "@")
-		require.Len(t, nameWithTagSplit, 2)
+		// NOTE(okozachenko1203): We'll enable this again when use image digest.
+		// require.Len(t, nameWithTagSplit, 2)
 		nameWithTag := nameWithTagSplit[0]
-		name := strings.Split(nameWithTag, ":")[0]
-		digest := strings.Split(image, "@")[1]
-		image := fmt.Sprintf("%s@%s", name, digest)
+		var imageRef string
+		if len(nameWithTagSplit) == 2 {
+			name := strings.Split(nameWithTag, ":")[0]
+			digest := strings.Split(image, "@")[1]
+			imageRef = fmt.Sprintf("%s@%s", name, digest)
+		} else {
+			imageRef = nameWithTag
+		}
 
-		t.Run(image, func(t *testing.T) {
+		t.Run(imageRef, func(t *testing.T) {
 			t.Parallel()
 
-			ref, err := docker.ParseReference(fmt.Sprintf("//%s", image))
+			ref, err := docker.ParseReference(fmt.Sprintf("//%s", imageRef))
 			require.NoError(t, err)
 
 			ctx := context.Background()
diff --git a/roles/percona_xtradb_cluster/vars_test.go b/roles/percona_xtradb_cluster/vars_test.go
index 8095308..943b9da 100644
--- a/roles/percona_xtradb_cluster/vars_test.go
+++ b/roles/percona_xtradb_cluster/vars_test.go
@@ -53,7 +53,7 @@
 func TestPerconaXtraDBClusterPXCSpec(t *testing.T) {
 	assert.Equal(t, int32(3), vars.PerconaXtraDBClusterSpec.PXC.Size)
 	assert.Equal(t, true, *vars.PerconaXtraDBClusterSpec.PXC.AutoRecovery)
-	defaults.AssertAtmosphereImage(t, "docker.io/percona/percona-xtradb-cluster:8.0.32-24.2@sha256:1f978ab8912e1b5fc66570529cb7e7a4ec6a38adbfce1ece78159b0fcfa7d47a", vars.PerconaXtraDBClusterSpec.PXC.Image)
+	defaults.AssertAtmosphereImage(t, "docker.io/percona/percona-xtradb-cluster:8.0.36-28.1", vars.PerconaXtraDBClusterSpec.PXC.Image)
 
 	assert.Equal(t, map[string]string{
 		"openstack-control-plane": "enabled",
@@ -92,10 +92,10 @@
 func TestPerconaXtraDBClusterPXCSidecarSpec(t *testing.T) {
 	sidecar := vars.PerconaXtraDBClusterSpec.PXC.Sidecars[0]
 	assert.Equal(t, "exporter", sidecar.Name)
-	defaults.AssertAtmosphereImage(t, "quay.io/prometheus/mysqld-exporter:v0.14.0@sha256:eb6fe170738bf9181c51f5bc89f93adb26672ec49ffdcb22f55c24834003b45d", sidecar.Image)
+	defaults.AssertAtmosphereImage(t, "quay.io/prometheus/mysqld-exporter:v0.15.1", sidecar.Image)
 
 	assert.Equal(t, v1.EnvVar{
-		Name: "MONITOR_PASSWORD",
+		Name: "MYSQLD_EXPORTER_PASSWORD",
 		ValueFrom: &v1.EnvVarSource{
 			SecretKeyRef: &v1.SecretKeySelector{
 				LocalObjectReference: v1.LocalObjectReference{
@@ -105,10 +105,6 @@
 			},
 		},
 	}, sidecar.Env[0])
-	assert.Equal(t, v1.EnvVar{
-		Name:  "DATA_SOURCE_NAME",
-		Value: "monitor:$(MONITOR_PASSWORD)@(localhost:3306)/",
-	}, sidecar.Env[1])
 
 	assert.Equal(t, v1.ContainerPort{
 		Name:          "metrics",
@@ -120,11 +116,8 @@
 	assert.Equal(t, true, vars.PerconaXtraDBClusterSpec.HAProxy.Enabled)
 	assert.Equal(t, int32(3), vars.PerconaXtraDBClusterSpec.HAProxy.Size)
 
-	chart, err := loader.LoadDir("../../charts/pxc-operator")
-	require.NoError(t, err)
-
 	defaults.AssertAtmosphereImage(t,
-		fmt.Sprintf("docker.io/percona/percona-xtradb-cluster-operator:%s-haproxy@sha256:f04e4fea548bfc7cb0bfc73c75c7f2c64d299cf04125a07a8101a55f0f734fed", chart.AppVersion()),
+		fmt.Sprintf("docker.io/percona/percona-xtradb-cluster-operator:%s-haproxy", vars.PerconaXtraDBClusterSpec.CRVersion),
 		vars.PerconaXtraDBClusterSpec.HAProxy.Image,
 	)
 
@@ -134,9 +127,6 @@
 }
 
 func TestPerconaXtraDBClusterHAProxyConfiguration(t *testing.T) {
-	chart, err := loader.LoadDir("../../charts/pxc-operator")
-	require.NoError(t, err)
-
 	pxcConfig := parsePXCConfiguration(t, vars.PerconaXtraDBClusterSpec.PXC.Configuration)
 	maxConnections := pxcConfig.Section("mysqld").Key("max_connections").MustInt()
 
@@ -145,7 +135,7 @@
 	//               then compare it.
 
 	// Get the default HAproxy configuration
-	configFileUrl := fmt.Sprintf("https://raw.githubusercontent.com/percona/percona-docker/pxc-operator-%s/haproxy/dockerdir/etc/haproxy/haproxy-global.cfg", chart.AppVersion())
+	configFileUrl := fmt.Sprintf("https://raw.githubusercontent.com/percona/percona-docker/pxc-operator-%s/haproxy/dockerdir/etc/haproxy/haproxy-global.cfg", vars.PerconaXtraDBClusterSpec.CRVersion)
 	resp, err := http.Get(configFileUrl)
 	require.NoError(t, err)
 	defer resp.Body.Close()
diff --git a/roles/placement/vars/main.yml b/roles/placement/vars/main.yml
index ef5e1ef..3353be7 100644
--- a/roles/placement/vars/main.yml
+++ b/roles/placement/vars/main.yml
@@ -27,6 +27,7 @@
         connection_recycle_time: 600
         max_overflow: 50
         max_pool_size: 5
+        max_retries: -1
         pool_timeout: 30
       oslo_messaging_notifications:
         driver: noop