Skip to content

Commit

Permalink
switch v1beta1 resoruces to use v1beta1 versions in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frodopwns committed May 13, 2020
1 parent 0ebecb1 commit d94b277
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: docker.io/frodopwns/op6:10
- image: controller:latest
name: manager
env:
- name: AZURE_CLIENT_ID
Expand Down
25 changes: 13 additions & 12 deletions controllers/azuresql_combined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/api/v1beta1"
"github.com/stretchr/testify/assert"

helpers "github.com/Azure/azure-service-operator/pkg/helpers"
Expand Down Expand Up @@ -38,10 +39,10 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
sqlServerNamespacedName2 := types.NamespacedName{Name: sqlServerTwoName, Namespace: "default"}

// Create the SqlServer object and expect the Reconcile to be created
sqlServerInstance := azurev1alpha1.NewAzureSQLServer(sqlServerNamespacedName, rgName, rgLocation)
sqlServerInstance := v1beta1.NewAzureSQLServer(sqlServerNamespacedName, rgName, rgLocation)

// Send request for 2nd server (failovergroup test) before waiting on first server
sqlServerInstance2 := azurev1alpha1.NewAzureSQLServer(sqlServerNamespacedName2, rgName, rgLocation2)
sqlServerInstance2 := v1beta1.NewAzureSQLServer(sqlServerNamespacedName2, rgName, rgLocation2)

// create and wait
RequireInstance(ctx, t, tc, sqlServerInstance)
Expand All @@ -60,7 +61,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
}, tc.timeoutFast, tc.retry, "wait for server to have secret")

sqlDatabaseName := GenerateTestResourceNameWithRandom("sqldatabase", 10)
var sqlDatabaseInstance *azurev1alpha1.AzureSqlDatabase
var sqlDatabaseInstance *v1beta1.AzureSqlDatabase

sqlFirewallRuleNamespacedNameLocal := types.NamespacedName{
Name: GenerateTestResourceNameWithRandom("sqlfwr-local", 10),
Expand All @@ -71,8 +72,8 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
Namespace: "default",
}

var sqlFirewallRuleInstanceLocal *azurev1alpha1.AzureSqlFirewallRule
var sqlFirewallRuleInstanceRemote *azurev1alpha1.AzureSqlFirewallRule
var sqlFirewallRuleInstanceLocal *v1beta1.AzureSqlFirewallRule
var sqlFirewallRuleInstanceRemote *v1beta1.AzureSqlFirewallRule

// run sub tests that require 1 sql server ----------------------------------
t.Run("group1", func(t *testing.T) {
Expand All @@ -92,12 +93,12 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
t.Parallel()

// Create the SqlDatabase object and expect the Reconcile to be created
sqlDatabaseInstance = &azurev1alpha1.AzureSqlDatabase{
sqlDatabaseInstance = &v1beta1.AzureSqlDatabase{
ObjectMeta: metav1.ObjectMeta{
Name: sqlDatabaseName,
Namespace: "default",
},
Spec: azurev1alpha1.AzureSqlDatabaseSpec{
Spec: v1beta1.AzureSqlDatabaseSpec{
Location: rgLocation,
ResourceGroup: rgName,
Server: sqlServerName,
Expand All @@ -114,7 +115,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
t.Parallel()

// Create the SqlFirewallRule object and expect the Reconcile to be created
sqlFirewallRuleInstanceLocal = azurev1alpha1.NewAzureSQLFirewallRule(
sqlFirewallRuleInstanceLocal = v1beta1.NewAzureSQLFirewallRule(
sqlFirewallRuleNamespacedNameLocal,
rgName,
sqlServerName,
Expand All @@ -129,7 +130,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
t.Parallel()

// Create the SqlFirewallRule object and expect the Reconcile to be created
sqlFirewallRuleInstanceRemote = azurev1alpha1.NewAzureSQLFirewallRule(
sqlFirewallRuleInstanceRemote = v1beta1.NewAzureSQLFirewallRule(
sqlFirewallRuleNamespacedNameRemote,
rgName,
sqlServerName,
Expand Down Expand Up @@ -316,7 +317,7 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
assert.Equal(oldSecret["username"], newSecret["username"], "usernames should be the same")
})

var sqlFailoverGroupInstance *azurev1alpha1.AzureSqlFailoverGroup
var sqlFailoverGroupInstance *v1beta1.AzureSqlFailoverGroup
sqlFailoverGroupName := GenerateTestResourceNameWithRandom("sqlfog-dev", 10)

sqlFailoverGroupNamespacedName := types.NamespacedName{Name: sqlFailoverGroupName, Namespace: "default"}
Expand Down Expand Up @@ -372,12 +373,12 @@ func TestAzureSqlServerCombinedHappyPath(t *testing.T) {
t.Parallel()

// Create the SqlFailoverGroup object and expect the Reconcile to be created
sqlFailoverGroupInstance = &azurev1alpha1.AzureSqlFailoverGroup{
sqlFailoverGroupInstance = &v1beta1.AzureSqlFailoverGroup{
ObjectMeta: metav1.ObjectMeta{
Name: sqlFailoverGroupNamespacedName.Name,
Namespace: sqlFailoverGroupNamespacedName.Namespace,
},
Spec: azurev1alpha1.AzureSqlFailoverGroupSpec{
Spec: v1beta1.AzureSqlFailoverGroupSpec{
Location: rgLocation,
ResourceGroup: rgName,
Server: sqlServerName,
Expand Down
11 changes: 5 additions & 6 deletions controllers/azuresqldatabase_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"context"
"testing"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"

"github.com/Azure/azure-service-operator/api/v1beta1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -26,12 +25,12 @@ func TestAzureSqlDatabaseControllerNoResourceGroup(t *testing.T) {
sqlDatabaseName := GenerateTestResourceNameWithRandom("sqldatabase-dev", 10)

// Create the SqlDatabase object and expect the Reconcile to be created
sqlDatabaseInstance := &azurev1alpha1.AzureSqlDatabase{
sqlDatabaseInstance := &v1beta1.AzureSqlDatabase{
ObjectMeta: metav1.ObjectMeta{
Name: sqlDatabaseName,
Namespace: "default",
},
Spec: azurev1alpha1.AzureSqlDatabaseSpec{
Spec: v1beta1.AzureSqlDatabaseSpec{
Location: rgLocation,
ResourceGroup: GenerateTestResourceNameWithRandom("rg-test-srv", 10),
Server: sqlServerName,
Expand All @@ -55,12 +54,12 @@ func TestAzureSqlDatabaseControllerNoServer(t *testing.T) {
sqlDatabaseName := GenerateTestResourceNameWithRandom("sqldatabase-dev", 10)

// Create the SqlDatabase object and expect the Reconcile to be created
sqlDatabaseInstance := &azurev1alpha1.AzureSqlDatabase{
sqlDatabaseInstance := &v1beta1.AzureSqlDatabase{
ObjectMeta: metav1.ObjectMeta{
Name: sqlDatabaseName,
Namespace: "default",
},
Spec: azurev1alpha1.AzureSqlDatabaseSpec{
Spec: v1beta1.AzureSqlDatabaseSpec{
Location: rgLocation,
ResourceGroup: rgName,
Server: sqlServerName,
Expand Down
7 changes: 3 additions & 4 deletions controllers/azuresqlfailovergroup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"context"
"testing"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"

"github.com/Azure/azure-service-operator/api/v1beta1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -35,12 +34,12 @@ func TestAzureSqlFailoverGroupControllerNoResourceGroup(t *testing.T) {
sqlFailoverGroupName := GenerateTestResourceNameWithRandom("sqlfog-dev", 10)

// Create the SqlFailoverGroup object and expect the Reconcile to be created
sqlFailoverGroupInstance := &azurev1alpha1.AzureSqlFailoverGroup{
sqlFailoverGroupInstance := &v1beta1.AzureSqlFailoverGroup{
ObjectMeta: metav1.ObjectMeta{
Name: sqlFailoverGroupName,
Namespace: "default",
},
Spec: azurev1alpha1.AzureSqlFailoverGroupSpec{
Spec: v1beta1.AzureSqlFailoverGroupSpec{
Location: rgLocation1,
ResourceGroup: GenerateTestResourceNameWithRandom("rg-fake", 10),
Server: sqlServerOneName,
Expand Down
7 changes: 3 additions & 4 deletions controllers/azuresqlfirewallrule_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"context"
"testing"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"

"github.com/Azure/azure-service-operator/api/v1beta1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -26,12 +25,12 @@ func TestAzureSqlFirewallRuleControllerNoResourceGroup(t *testing.T) {
sqlFirewallRuleName := GenerateTestResourceNameWithRandom("fwrule-dev", 10)

// Create the SqlFirewallRule object and expect the Reconcile to be created
sqlFirewallRuleInstance := &azurev1alpha1.AzureSqlFirewallRule{
sqlFirewallRuleInstance := &v1beta1.AzureSqlFirewallRule{
ObjectMeta: metav1.ObjectMeta{
Name: sqlFirewallRuleName,
Namespace: "default",
},
Spec: azurev1alpha1.AzureSqlFirewallRuleSpec{
Spec: v1beta1.AzureSqlFirewallRuleSpec{
ResourceGroup: GenerateTestResourceNameWithRandom("rg-fake-srv", 10),
Server: sqlServerName,
StartIPAddress: "0.0.0.0",
Expand Down
6 changes: 3 additions & 3 deletions controllers/azuresqlserver_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"context"
"testing"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/api/v1beta1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -22,12 +22,12 @@ func TestAzureSqlServerControllerNoResourceGroup(t *testing.T) {
sqlServerName := GenerateTestResourceNameWithRandom("sqlserver-dev", 10)

// Create the SqlServer object and expect the Reconcile to be created
sqlServerInstance := &azurev1alpha1.AzureSqlServer{
sqlServerInstance := &v1beta1.AzureSqlServer{
ObjectMeta: metav1.ObjectMeta{
Name: sqlServerName,
Namespace: "default",
},
Spec: azurev1alpha1.AzureSqlServerSpec{
Spec: v1beta1.AzureSqlServerSpec{
Location: tc.resourceGroupLocation,
ResourceGroup: GenerateTestResourceNameWithRandom("rg-fake-dev", 10),
},
Expand Down
15 changes: 7 additions & 8 deletions controllers/blobcontainer_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
s "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage"
"github.com/Azure/go-autorest/autorest/to"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
helpers "github.com/Azure/azure-service-operator/pkg/helpers"

Expand All @@ -37,15 +36,15 @@ func TestBlobContainerControlleNoResourceGroup(t *testing.T) {
resourceGroupName := GenerateTestResourceNameWithRandom("rg", 10)

// Create Storage account
saInstance := &azurev1alpha1.StorageAccount{
saInstance := &v1alpha2.StorageAccount{
ObjectMeta: metav1.ObjectMeta{
Name: saName,
Namespace: "default",
},
Spec: azurev1alpha1.StorageAccountSpec{
Spec: v1alpha2.StorageAccountSpec{
Location: tc.resourceGroupLocation,
ResourceGroup: tc.resourceGroupName,
Sku: azurev1alpha1.StorageAccountSku{
Sku: v1alpha2.StorageAccountSku{
Name: "Standard_RAGRS",
},
Kind: "StorageV2",
Expand All @@ -55,12 +54,12 @@ func TestBlobContainerControlleNoResourceGroup(t *testing.T) {
}
EnsureInstance(ctx, t, tc, saInstance)

blobContainerInstance := &azurev1alpha1.BlobContainer{
blobContainerInstance := &v1alpha2.BlobContainer{
ObjectMeta: metav1.ObjectMeta{
Name: blobContainerName,
Namespace: "default",
},
Spec: azurev1alpha1.BlobContainerSpec{
Spec: v1alpha2.BlobContainerSpec{
Location: rgLocation,
ResourceGroup: resourceGroupName,
AccountName: saName,
Expand Down Expand Up @@ -89,12 +88,12 @@ func TestTestBlobContainerControllerNoStorageAccount(t *testing.T) {
blobContainerName := GenerateTestResourceNameWithRandom("bc", 10)
storageAccountName := helpers.FillWithRandom(GenerateAlphaNumTestResourceName("sa"), 24)

blobContainerInstance := &azurev1alpha1.BlobContainer{
blobContainerInstance := &v1alpha2.BlobContainer{
ObjectMeta: metav1.ObjectMeta{
Name: blobContainerName,
Namespace: "default",
},
Spec: azurev1alpha1.BlobContainerSpec{
Spec: v1alpha2.BlobContainerSpec{
Location: rgLocation,
ResourceGroup: rgName,
AccountName: storageAccountName,
Expand Down
5 changes: 3 additions & 2 deletions controllers/mysql_combined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/api/v1alpha2"
)

func TestMySQLHappyPath(t *testing.T) {
Expand All @@ -26,12 +27,12 @@ func TestMySQLHappyPath(t *testing.T) {
mySQLReplicaName := GenerateTestResourceNameWithRandom("mysql-rep", 10)

// Create the mySQLServer object and expect the Reconcile to be created
mySQLServerInstance := azurev1alpha1.NewDefaultMySQLServer(mySQLServerName, rgName, rgLocation)
mySQLServerInstance := v1alpha2.NewDefaultMySQLServer(mySQLServerName, rgName, rgLocation)

RequireInstance(ctx, t, tc, mySQLServerInstance)

// Create a mySQL replica
mySQLReplicaInstance := azurev1alpha1.NewReplicaMySQLServer(mySQLReplicaName, rgName, rgLocation, mySQLServerInstance.Status.ResourceId)
mySQLReplicaInstance := v1alpha2.NewReplicaMySQLServer(mySQLReplicaName, rgName, rgLocation, mySQLServerInstance.Status.ResourceId)

EnsureInstance(ctx, t, tc, mySQLReplicaInstance)

Expand Down

0 comments on commit d94b277

Please sign in to comment.