-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'buhongw7583c-issue#858'
- Loading branch information
Showing
21 changed files
with
516 additions
and
108 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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
# Change the value of image field below to your controller image URL | ||
- image: controller:latest | ||
name: manager | ||
env: | ||
- name: AZURE_CLIENT_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_CLIENT_ID | ||
optional: true | ||
- name: AZURE_CLIENT_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_CLIENT_SECRET | ||
optional: true | ||
- name: AZURE_TENANT_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_TENANT_ID | ||
- name: AZURE_SUBSCRIPTION_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_SUBSCRIPTION_ID | ||
- name: AZURE_USE_MI | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_USE_MI | ||
optional: true | ||
- name: AZURE_OPERATOR_KEYVAULT | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_OPERATOR_KEYVAULT | ||
optional: true | ||
#requeue after time in seconds" | ||
- name: REQUEUE_AFTER | ||
value: "30" |
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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// +build all psqldatabase | ||
|
||
package controllers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" | ||
"github.com/Azure/azure-service-operator/pkg/errhelp" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
//Postgresql database controller unhappy test cases | ||
|
||
func TestPSQLDatabaseControllerNoResourceGroup(t *testing.T) { | ||
t.Parallel() | ||
defer PanicRecover(t) | ||
ctx := context.Background() | ||
|
||
// Add any setup steps that needs to be executed before each test | ||
rgName := GenerateTestResourceNameWithRandom("psqlsrv-rg", 10) | ||
|
||
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10) | ||
postgreSQLDatabaseName := GenerateTestResourceNameWithRandom("psql-db", 10) | ||
|
||
// Create the PostgreSQLDatabase object and expect the Reconcile to be created | ||
postgreSQLDatabaseInstance1 := &azurev1alpha1.PostgreSQLDatabase{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: postgreSQLDatabaseName, | ||
Namespace: "default", | ||
}, | ||
Spec: azurev1alpha1.PostgreSQLDatabaseSpec{ | ||
ResourceGroup: rgName, | ||
Server: postgreSQLServerName, | ||
}, | ||
} | ||
|
||
EnsureInstanceWithResult(ctx, t, tc, postgreSQLDatabaseInstance1, errhelp.ResourceGroupNotFoundErrorCode, false) | ||
EnsureDelete(ctx, t, tc, postgreSQLDatabaseInstance1) | ||
|
||
} | ||
|
||
func TestPSQLDatabaseControllerNoSever(t *testing.T) { | ||
t.Parallel() | ||
defer PanicRecover(t) | ||
ctx := context.Background() | ||
|
||
// Add any setup steps that needs to be executed before each test | ||
rgName := tc.resourceGroupName | ||
|
||
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10) | ||
postgreSQLDatabaseName := GenerateTestResourceNameWithRandom("psql-db", 10) | ||
|
||
// Create the PostgreSQLDatabase object and expect the Reconcile to be created | ||
postgreSQLDatabaseInstance2 := &azurev1alpha1.PostgreSQLDatabase{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: postgreSQLDatabaseName, | ||
Namespace: "default", | ||
}, | ||
Spec: azurev1alpha1.PostgreSQLDatabaseSpec{ | ||
ResourceGroup: rgName, | ||
Server: postgreSQLServerName, | ||
}, | ||
} | ||
|
||
EnsureInstanceWithResult(ctx, t, tc, postgreSQLDatabaseInstance2, errhelp.ResourceNotFound, false) | ||
EnsureDelete(ctx, t, tc, postgreSQLDatabaseInstance2) | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// +build all psqlfirewallrule | ||
|
||
package controllers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" | ||
"github.com/Azure/azure-service-operator/pkg/errhelp" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestPSQLFirewallRuleControllerNoResourceGroup(t *testing.T) { | ||
t.Parallel() | ||
defer PanicRecover(t) | ||
ctx := context.Background() | ||
|
||
// Add any setup steps that needs to be executed before each test | ||
rgName := GenerateTestResourceNameWithRandom("psqlsrv-rg", 10) | ||
|
||
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10) | ||
postgreSQLFirewallRuleName := GenerateTestResourceNameWithRandom("psql-fwrule", 10) | ||
|
||
// Create the PostgreSQLFirewallRule object and expect the Reconcile to be created | ||
postgreSQLFirewallRuleInstance := &azurev1alpha1.PostgreSQLFirewallRule{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: postgreSQLFirewallRuleName, | ||
Namespace: "default", | ||
}, | ||
Spec: azurev1alpha1.PostgreSQLFirewallRuleSpec{ | ||
ResourceGroup: rgName, | ||
Server: postgreSQLServerName, | ||
StartIPAddress: "0.0.0.0", | ||
EndIPAddress: "0.0.0.0", | ||
}, | ||
} | ||
|
||
EnsureInstanceWithResult(ctx, t, tc, postgreSQLFirewallRuleInstance, errhelp.ResourceGroupNotFoundErrorCode, false) | ||
EnsureDelete(ctx, t, tc, postgreSQLFirewallRuleInstance) | ||
|
||
} | ||
|
||
func TestPSQLFirewallRuleControllerNoServer(t *testing.T) { | ||
t.Parallel() | ||
defer PanicRecover(t) | ||
ctx := context.Background() | ||
|
||
// Add any setup steps that needs to be executed before each test | ||
rgName := tc.resourceGroupName | ||
|
||
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10) | ||
postgreSQLFirewallRuleName := GenerateTestResourceNameWithRandom("psql-fwrule", 10) | ||
|
||
// Create the PostgreSQLFirewallRule object and expect the Reconcile to be created | ||
postgreSQLFirewallRuleInstance := &azurev1alpha1.PostgreSQLFirewallRule{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: postgreSQLFirewallRuleName, | ||
Namespace: "default", | ||
}, | ||
Spec: azurev1alpha1.PostgreSQLFirewallRuleSpec{ | ||
ResourceGroup: rgName, | ||
Server: postgreSQLServerName, | ||
StartIPAddress: "0.0.0.0", | ||
EndIPAddress: "0.0.0.0", | ||
}, | ||
} | ||
|
||
EnsureInstanceWithResult(ctx, t, tc, postgreSQLFirewallRuleInstance, errhelp.ResourceNotFound, false) | ||
EnsureDelete(ctx, t, tc, postgreSQLFirewallRuleInstance) | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// +build all psqlserver | ||
|
||
package controllers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" | ||
"github.com/Azure/azure-service-operator/pkg/errhelp" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
//test Postgre SQL server unhappy path | ||
func TestPSQLServerControllerNoResourceGroup(t *testing.T) { | ||
t.Parallel() | ||
defer PanicRecover(t) | ||
ctx := context.Background() | ||
|
||
// Add any setup steps that needs to be executed before each test | ||
rgName := GenerateTestResourceNameWithRandom("psqlsrv-rg", 10) | ||
rgLocation := tc.resourceGroupLocation | ||
|
||
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10) | ||
|
||
// Create the PostgreSQLServer object and expect the Reconcile to be created | ||
postgreSQLServerInstance := &azurev1alpha1.PostgreSQLServer{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: postgreSQLServerName, | ||
Namespace: "default", | ||
}, | ||
Spec: azurev1alpha1.PostgreSQLServerSpec{ | ||
Location: rgLocation, | ||
ResourceGroup: rgName, | ||
Sku: azurev1alpha1.AzureDBsSQLSku{ | ||
Name: "B_Gen5_2", | ||
Tier: azurev1alpha1.SkuTier("Basic"), | ||
Family: "Gen5", | ||
Size: "51200", | ||
Capacity: 2, | ||
}, | ||
ServerVersion: azurev1alpha1.ServerVersion("10"), | ||
SSLEnforcement: azurev1alpha1.SslEnforcementEnumEnabled, | ||
}, | ||
} | ||
EnsureInstanceWithResult(ctx, t, tc, postgreSQLServerInstance, errhelp.ResourceGroupNotFoundErrorCode, false) | ||
EnsureDelete(ctx, t, tc, postgreSQLServerInstance) | ||
|
||
} |
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
Oops, something went wrong.