Skip to content

Commit

Permalink
Merge branch 'master' into failovergroupopr
Browse files Browse the repository at this point in the history
  • Loading branch information
jananivMS authored Oct 24, 2019
2 parents d849b9c + 88a973e commit 3e42894
Show file tree
Hide file tree
Showing 38 changed files with 766 additions and 381 deletions.
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@ For information on how to build, test and run the operator, refer to the link be
2. [EventHub](/docs/eventhub/eventhub.md)
3. [Azure SQL](/docs/azuresql/azuresql.md)


## Testing

Testing the full project can be done in two ways:
* `make test` - Test against the Kubernetes integration testing framework.
* `make test-existing` - Test against an existing cluster. This is currently easiest to do run against a kind cluster setup.

Both of these invoke the Ginkgo test runner, running tests in parallel across 4 nodes by default.

### Focus tests

The ginkgo runner makes it simple to test single test cases, or packages in isolation.
* Rename the spec from `Describe` to `FDescribe`, or the individual test case from `It` to `FIt` excludes all other tests at the same level.
* Adding an additional parameter to ginkgo runner `--focus=REGEXP`.

See [https://onsi.github.io/ginkgo/#focused-specs]() for more details.


### Help

1. If the secret for the Eventhub in k8s gets deleted accidentally, the reconcile for the parent eventhub is triggered and secret gets created again.
2. If EventhubNamespace and Eventhub are deleted in Azure, then we need to delete the objects in k8s for the resources to be recreated. Reason being, if we apply the same manifest k8s does it recognise it as a change and the reconcile is not triggered.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand All @@ -65,6 +42,8 @@ When you submit a pull request, a CLA bot will automatically determine whether y
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

For more specific information on the GIT workflow and guidelines to follow, check [here](docs/contributionguidelines.md).

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
23 changes: 23 additions & 0 deletions api/v1alpha1/aso_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

// AzureServiceOperatorsStatus (ASOStatus) defines the observed state of resource actions
type ASOStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
State string `json:"state,omitempty"`
Message string `json:"message,omitempty"`
}
11 changes: 1 addition & 10 deletions api/v1alpha1/azuresqlaction_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ type AzureSqlActionSpec struct {
ServerName string `json:"servername"`
}

// AzureSqlActionStatus defines the observed state of AzureSqlAction
type AzureSqlActionStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
Message string `json:"state,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

Expand All @@ -49,7 +40,7 @@ type AzureSqlAction struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureSqlActionSpec `json:"spec,omitempty"`
Status AzureSqlActionStatus `json:"status,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
81 changes: 81 additions & 0 deletions api/v1alpha1/azuresqlaction_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// These tests are written in BDD-style using Ginkgo framework. Refer to
// http://onsi.github.io/ginkgo to learn more.

var _ = Describe("AzureSqlAction", func() {
var (
key types.NamespacedName
created, fetched *AzureSqlAction
)

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

AfterEach(func() {
// Add any teardown steps that needs to be executed after each test
})

// Add Tests for OpenAPI validation (or additonal CRD features) specified in
// your API definition.
// Avoid adding tests for vanilla CRUD operations because they would
// test Kubernetes API server, which isn't the goal here.
Context("Create API", func() {

It("should create an object successfully", func() {

key = types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created = &AzureSqlAction{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: AzureSqlActionSpec{
ResourceGroup: "foo-action",
ServerName: "sqlsrvsample",
ActionName: "rollcreds",
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &AzureSqlAction{}
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed())
Expect(fetched).To(Equal(created))

By("deleting the created object")
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed())
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed())
})

})

})
10 changes: 1 addition & 9 deletions api/v1alpha1/azuresqldatabase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ type AzureSqlDatabaseSpec struct {
Edition sql.DBEdition `json:"edition"`
}

// AzureSqlDatabaseStatus defines the observed state of AzureSqlDatabase
type AzureSqlDatabaseStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// AzureSqlDatabase is the Schema for the azuresqldatabases API
Expand All @@ -48,7 +40,7 @@ type AzureSqlDatabase struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureSqlDatabaseSpec `json:"spec,omitempty"`
Status AzureSqlDatabaseStatus `json:"status,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
11 changes: 1 addition & 10 deletions api/v1alpha1/azuresqlfirewallrule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ type AzureSqlFirewallRuleSpec struct {
EndIPAddress string `json:"endipaddress,omitempty"`
}

// AzureSqlFirewallRuleStatus defines the observed state of AzureSqlFirewallRule
type AzureSqlFirewallRuleStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
Message string `json:"message,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// AzureSqlFirewallRule is the Schema for the azuresqlfirewallrules API
Expand All @@ -49,7 +40,7 @@ type AzureSqlFirewallRule struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureSqlFirewallRuleSpec `json:"spec,omitempty"`
Status AzureSqlFirewallRuleStatus `json:"status,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
82 changes: 82 additions & 0 deletions api/v1alpha1/azuresqlfirewallrule_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// These tests are written in BDD-style using Ginkgo framework. Refer to
// http://onsi.github.io/ginkgo to learn more.

var _ = Describe("AzureSqlFirewallRule", func() {
var (
key types.NamespacedName
created, fetched *AzureSqlFirewallRule
)

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

AfterEach(func() {
// Add any teardown steps that needs to be executed after each test
})

// Add Tests for OpenAPI validation (or additonal CRD features) specified in
// your API definition.
// Avoid adding tests for vanilla CRUD operations because they would
// test Kubernetes API server, which isn't the goal here.
Context("Create API", func() {

It("should create an object successfully", func() {

key = types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created = &AzureSqlFirewallRule{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: AzureSqlFirewallRuleSpec{
ResourceGroup: "foo-firewallrule",
Server: "sqlsrvsample",
StartIPAddress: "0.0.0.0",
EndIPAddress: "0.0.0.0",
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &AzureSqlFirewallRule{}
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed())
Expect(fetched).To(Equal(created))

By("deleting the created object")
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed())
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed())
})

})

})
12 changes: 1 addition & 11 deletions api/v1alpha1/azuresqlserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ type AzureSqlServerSpec struct {
ResourceGroup string `json:"resourcegroup,omitempty"`
}

// AzureSqlServerStatus defines the observed state of AzureSqlServer
type AzureSqlServerStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
State string `json:"state,omitempty"`
Message string `json:"message,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// AzureSqlServer is the Schema for the azuresqlservers API
Expand All @@ -48,7 +38,7 @@ type AzureSqlServer struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureSqlServerSpec `json:"spec,omitempty"`
Status AzureSqlServerStatus `json:"status,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
10 changes: 1 addition & 9 deletions api/v1alpha1/consumergroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ type ConsumerGroupSpec struct {
AzureConsumerGroupName string `json:"consumerGroupName,omitempty"`
}

// ConsumerGroupStatus defines the observed state of ConsumerGroup
type ConsumerGroupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
}

// +kubebuilder:object:root=true

// ConsumerGroup is the Schema for the consumergroups API
Expand All @@ -49,7 +41,7 @@ type ConsumerGroup struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ConsumerGroupSpec `json:"spec,omitempty"`
Status ConsumerGroupStatus `json:"status,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
14 changes: 1 addition & 13 deletions api/v1alpha1/cosmosdb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@ type CosmosDBLocation struct {
}
*/

// CosmosDBStatus defines the observed state of CosmosDB
type CosmosDBStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// DeploymentName string `json:"deploymentName,omitempty"`
// ProvisioningState string `json:"provisioningState,omitempty"`
// Generation int64 `json:"generation,omitempty"`
Provisioning bool `json:"provisioning,omitempty"`
Provisioned bool `json:"provisioned,omitempty"`
}

type CosmosDBOutput struct {
CosmosDBName string `json:"cosmosDBName,omitempty"`
PrimaryMasterKey string `json:"primaryMasterKey,omitempty"`
Expand All @@ -112,7 +100,7 @@ type CosmosDB struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CosmosDBSpec `json:"spec,omitempty"`
Status CosmosDBStatus `json:"status,omitempty"`
Status ASOStatus `json:"status,omitempty"`
Output CosmosDBOutput `json:"output,omitempty"`
AdditionalResources CosmosDBAdditionalResources `json:"additionalResources,omitempty"`
}
Expand Down
Loading

0 comments on commit 3e42894

Please # to comment.