Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

randomize the resources names used in tests #152

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions controllers/consumergroup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ import (
var _ = Describe("ConsumerGroup Controller", func() {

const timeout = time.Second * 240
var rgName string
var ehnName string
var ehName string

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
rgName = resourceGroupName
ehnName = eventhubNamespaceName
ehName = eventhubName

})

AfterEach(func() {
Expand All @@ -50,9 +57,6 @@ var _ = Describe("ConsumerGroup Controller", func() {
Context("Create and Delete", func() {
It("should create and delete consumer groups", func() {

resourceGroupName = "t-rg-dev-controller"
eventhubNamespaceName = "t-ns-dev-eh-ns"
eventhubName = "t-eh-dev-sample"
consumerGroupName := "t-cg-" + helpers.RandomString(10)

var err error
Expand All @@ -64,9 +68,9 @@ var _ = Describe("ConsumerGroup Controller", func() {
Namespace: "default",
},
Spec: azurev1.ConsumerGroupSpec{
NamespaceName: eventhubNamespaceName,
ResourceGroupName: resourceGroupName,
EventhubName: eventhubName,
NamespaceName: ehnName,
ResourceGroupName: rgName,
EventhubName: ehName,
},
}

Expand Down
11 changes: 7 additions & 4 deletions controllers/eventhub_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ var _ = Describe("EventHub Controller", func() {

const timeout = time.Second * 240

var rgName string
var ehnName string

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
rgName = resourceGroupName
ehnName = eventhubNamespaceName
})

AfterEach(func() {
Expand Down Expand Up @@ -83,8 +88,6 @@ var _ = Describe("EventHub Controller", func() {

It("should create and delete eventhubs", func() {

resourceGroupName = "t-rg-dev-controller"
eventhubNamespaceName = "t-ns-dev-eh-ns"
eventhubName := "t-eh-" + helpers.RandomString(10)

var err error
Expand All @@ -97,8 +100,8 @@ var _ = Describe("EventHub Controller", func() {
},
Spec: azurev1.EventhubSpec{
Location: "westus",
Namespace: eventhubNamespaceName,
ResourceGroup: resourceGroupName,
Namespace: ehnName,
ResourceGroup: rgName,
Properties: azurev1.EventhubProperties{
MessageRetentionInDays: 7,
PartitionCount: 1,
Expand Down
5 changes: 3 additions & 2 deletions controllers/eventhubnamespace_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ import (
var _ = Describe("EventHubNamespace Controller", func() {

const timeout = time.Second * 240
var rgName string

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
rgName = resourceGroupName

})

Expand Down Expand Up @@ -110,7 +112,6 @@ var _ = Describe("EventHubNamespace Controller", func() {

It("should create and delete namespace in k8s", func() {

resourceGroupName := "t-rg-dev-controller"
eventhubNamespaceName := "t-ns-dev-eh-" + helpers.RandomString(10)

var err error
Expand All @@ -123,7 +124,7 @@ var _ = Describe("EventHubNamespace Controller", func() {
},
Spec: azurev1.EventhubNamespaceSpec{
Location: "westus",
ResourceGroup: resourceGroupName,
ResourceGroup: rgName,
},
}

Expand Down
7 changes: 4 additions & 3 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package controllers

import (
"context"
helpers "github.com/Azure/azure-service-operator/pkg/helpers"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -55,11 +56,11 @@ var namespaceLocation string
func TestAPIs(t *testing.T) {
t.Parallel()
RegisterFailHandler(Fail)
resourceGroupName = "t-rg-dev-controller"
resourceGroupName = "t-rg-dev-controller-" + helpers.RandomString(10)
resourcegroupLocation = "westus"

eventhubNamespaceName = "t-ns-dev-eh-ns"
eventhubName = "t-eh-dev-sample"
eventhubNamespaceName = "t-ns-dev-eh-ns-" + helpers.RandomString(10)
eventhubName = "t-eh-dev-sample-" + helpers.RandomString(10)
namespaceLocation = "westus"
RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
Expand Down
18 changes: 9 additions & 9 deletions pkg/resourcemanager/eventhubs/consumergroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
var _ = Describe("ConsumerGroup", func() {

const timeout = time.Second * 240
var resourceGroupName string
var rgName string
var eventhubNamespaceName string
var eventhubName string
var namespaceLocation string
Expand All @@ -37,16 +37,16 @@ var _ = Describe("ConsumerGroup", func() {

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
resourceGroupName = "t-rg-dev-rm-eh"
rgName = resourceGroupName
eventhubNamespaceName = "t-ns-dev-eh-" + helpers.RandomString(10)
namespaceLocation = "westus"
eventhubName = "t-eh-dev-ehs"
eventhubName = "t-eh-dev-ehs-" + helpers.RandomString(10)
messageRetentionInDays = int32(7)
partitionCount = int32(1)

_, _ = CreateNamespaceAndWait(context.Background(), resourceGroupName, eventhubNamespaceName, namespaceLocation)
_, _ = CreateNamespaceAndWait(context.Background(), rgName, eventhubNamespaceName, namespaceLocation)

_, _ = CreateHub(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, messageRetentionInDays, partitionCount)
_, _ = CreateHub(context.Background(), rgName, eventhubNamespaceName, eventhubName, messageRetentionInDays, partitionCount)

})

Expand All @@ -66,20 +66,20 @@ var _ = Describe("ConsumerGroup", func() {

var err error

_, err = CreateConsumerGroup(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, consumerGroupName)
_, err = CreateConsumerGroup(context.Background(), rgName, eventhubNamespaceName, eventhubName, consumerGroupName)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := GetConsumerGroup(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, consumerGroupName)
result, _ := GetConsumerGroup(context.Background(), rgName, eventhubNamespaceName, eventhubName, consumerGroupName)
return result.Response.StatusCode == 200
}, timeout,
).Should(BeTrue())

_, err = DeleteConsumerGroup(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, consumerGroupName)
_, err = DeleteConsumerGroup(context.Background(), rgName, eventhubNamespaceName, eventhubName, consumerGroupName)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := GetConsumerGroup(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, consumerGroupName)
result, _ := GetConsumerGroup(context.Background(), rgName, eventhubNamespaceName, eventhubName, consumerGroupName)
return result.Response.StatusCode == 404
}, timeout,
).Should(BeTrue())
Expand Down
16 changes: 8 additions & 8 deletions pkg/resourcemanager/eventhubs/hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
var _ = Describe("Eventhub", func() {

const timeout = time.Second * 240
var resourceGroupName string
var rgName string
var eventhubNamespaceName string
var namespaceLocation string

BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
resourceGroupName = "t-rg-dev-rm-eh"
rgName = resourceGroupName
eventhubNamespaceName = "t-ns-dev-eh-" + helpers.RandomString(10)
namespaceLocation = "westus"

Expand All @@ -61,11 +61,11 @@ var _ = Describe("Eventhub", func() {

var err error

_, err = CreateHub(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, messageRetentionInDays, partitionCount)
_, err = CreateHub(context.Background(), rgName, eventhubNamespaceName, eventhubName, messageRetentionInDays, partitionCount)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := GetHub(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName)
result, _ := GetHub(context.Background(), rgName, eventhubNamespaceName, eventhubName)
return result.Response.StatusCode == 200
}, timeout,
).Should(BeTrue())
Expand All @@ -78,20 +78,20 @@ var _ = Describe("Eventhub", func() {
},
}

_, err = CreateOrUpdateAuthorizationRule(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, authorizationRuleName, parameters)
_, err = CreateOrUpdateAuthorizationRule(context.Background(), rgName, eventhubNamespaceName, eventhubName, authorizationRuleName, parameters)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := ListKeys(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName, authorizationRuleName)
result, _ := ListKeys(context.Background(), rgName, eventhubNamespaceName, eventhubName, authorizationRuleName)
return result.Response.StatusCode == 200
}, timeout,
).Should(BeTrue())

_, err = DeleteHub(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName)
_, err = DeleteHub(context.Background(), rgName, eventhubNamespaceName, eventhubName)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := GetHub(context.Background(), resourceGroupName, eventhubNamespaceName, eventhubName)
result, _ := GetHub(context.Background(), rgName, eventhubNamespaceName, eventhubName)
return result.Response.StatusCode == 404
}, timeout,
).Should(BeTrue())
Expand Down
11 changes: 6 additions & 5 deletions pkg/resourcemanager/eventhubs/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ var _ = Describe("Namespace", func() {

const timeout = time.Second * 240

var rgName string
BeforeEach(func() {
// Add any setup steps that needs to be executed before each test
rgName = resourceGroupName
})

AfterEach(func() {
Expand All @@ -45,26 +47,25 @@ var _ = Describe("Namespace", func() {
Context("Create and Delete", func() {
It("should create and delete namespace in azure", func() {

resourceGroupName := "t-rg-dev-rm-eh"
eventhubNamespaceName := "t-ns-dev-eh-" + helpers.RandomString(10)
namespaceLocation := "westus"

var err error

_, err = CreateNamespaceAndWait(context.Background(), resourceGroupName, eventhubNamespaceName, namespaceLocation)
_, err = CreateNamespaceAndWait(context.Background(), rgName, eventhubNamespaceName, namespaceLocation)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := GetNamespace(context.Background(), resourceGroupName, eventhubNamespaceName)
result, _ := GetNamespace(context.Background(), rgName, eventhubNamespaceName)
return result.Response.StatusCode == 200
}, timeout,
).Should(BeTrue())

_, err = DeleteNamespace(context.Background(), resourceGroupName, eventhubNamespaceName)
_, err = DeleteNamespace(context.Background(), rgName, eventhubNamespaceName)
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
result, _ := GetNamespace(context.Background(), resourceGroupName, eventhubNamespaceName)
result, _ := GetNamespace(context.Background(), rgName, eventhubNamespaceName)
return result.Response.StatusCode == 404
}, timeout,
).Should(BeTrue())
Expand Down
3 changes: 2 additions & 1 deletion pkg/resourcemanager/eventhubs/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"context"

helpers "github.com/Azure/azure-service-operator/pkg/helpers"
"k8s.io/client-go/rest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand All @@ -45,7 +46,7 @@ func TestAPIs(t *testing.T) {
t.Skip("skipping Resource Manager Eventhubs Suite")
}
RegisterFailHandler(Fail)
resourceGroupName = "t-rg-dev-rm-eh"
resourceGroupName = "t-rg-dev-rm-eh-" + helpers.RandomString(10)
resourcegroupLocation = "westus"

RunSpecs(t, "Eventhubs Suite")
Expand Down