-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service): add service technical email support
- Loading branch information
Showing
4 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ import ( | |
mysqluserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/service/mysql" | ||
) | ||
|
||
func getMySQLYaml(project, name, cloudName string) string { | ||
return fmt.Sprintf(` | ||
func getMySQLYaml(project, name, cloudName string, includeTechnicalEmails bool) string { | ||
baseYaml := ` | ||
apiVersion: aiven.io/v1alpha1 | ||
kind: MySQL | ||
metadata: | ||
|
@@ -39,8 +39,16 @@ spec: | |
- network: 0.0.0.0/32 | ||
description: bar | ||
- network: 10.20.0.0/16 | ||
` | ||
|
||
`, project, name, cloudName) | ||
if includeTechnicalEmails { | ||
baseYaml += ` | ||
technicalEmails: | ||
- email: "[email protected]" | ||
` | ||
} | ||
|
||
return fmt.Sprintf(baseYaml, project, name, cloudName) | ||
} | ||
|
||
func TestMySQL(t *testing.T) { | ||
|
@@ -50,7 +58,7 @@ func TestMySQL(t *testing.T) { | |
// GIVEN | ||
ctx := context.Background() | ||
name := randName("mysql") | ||
yml := getMySQLYaml(testProject, name, testPrimaryCloudName) | ||
yml := getMySQLYaml(testProject, name, testPrimaryCloudName, false) | ||
s := NewSession(k8sClient, avnClient, testProject) | ||
|
||
// Cleans test afterwards | ||
|
@@ -112,3 +120,48 @@ func TestMySQL(t *testing.T) { | |
assert.NotEmpty(t, secret.Data["MYSQL_URI"]) | ||
assert.NotEmpty(t, secret.Data["MYSQL_REPLICA_URI"]) // business-4 has replica | ||
} | ||
|
||
func TestMySQLTechnicalEmails(t *testing.T) { | ||
t.Parallel() | ||
defer recoverPanic(t) | ||
|
||
// GIVEN | ||
ctx := context.Background() | ||
name := randName("mysql") | ||
yml := getMySQLYaml(testProject, name, testPrimaryCloudName, true) | ||
s := NewSession(k8sClient, avnClient, testProject) | ||
|
||
// Cleans test afterwards | ||
defer s.Destroy() | ||
|
||
// WHEN | ||
// Applies given manifest | ||
require.NoError(t, s.Apply(yml)) | ||
|
||
// Waits kube objects | ||
ms := new(v1alpha1.MySQL) | ||
require.NoError(t, s.GetRunning(ms, name)) | ||
|
||
// THEN | ||
// Technical emails are set | ||
msAvn, err := avnClient.Services.Get(ctx, testProject, name) | ||
require.NoError(t, err) | ||
assert.Len(t, ms.Spec.TechnicalEmails, 1) | ||
assert.Equal(t, "[email protected]", msAvn.TechnicalEmails[0].Email) | ||
|
||
// WHEN | ||
// Technical emails are removed from manifest | ||
updatedYml := getMySQLYaml(testProject, name, testPrimaryCloudName, false) | ||
|
||
// Applies updated manifest | ||
require.NoError(t, s.Apply(updatedYml)) | ||
|
||
// Waits kube objects | ||
require.NoError(t, s.GetRunning(ms, name)) | ||
|
||
// THEN | ||
// Technical emails are removed from service | ||
msAvnUpdated, err := avnClient.Services.Get(ctx, testProject, name) | ||
require.NoError(t, err) | ||
assert.Empty(t, msAvnUpdated.TechnicalEmails) | ||
} |