-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into apim-docs
- Loading branch information
Showing
4 changed files
with
201 additions
and
1 deletion.
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,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) | ||
|
||
} |