Skip to content

Commit

Permalink
Fixed GCP test
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-karpukhin committed Oct 23, 2023
1 parent 971bc4c commit a8b1b38
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 15 deletions.
36 changes: 34 additions & 2 deletions config/crd/bases/atlas.mongodb.com_atlasdeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ spec:
https://www.mongodb.com/docs/atlas/reference/api/clusters/
properties:
backupEnabled:
description: Applicable only for M10+ deployments. Flag that indicates
if the deployment uses Cloud Backups for backups.
type: boolean
biConnector:
description: BiConnectorSpec specifies BI Connector for Atlas
configuration on this deployment
description: Configuration of BI Connector for Atlas on this deployment.
The MongoDB Connector for Business Intelligence for Atlas (BI
Connector) is only available for M10 and larger deployments.
properties:
enabled:
description: Flag that indicates whether or not BI Connector
Expand All @@ -71,6 +74,13 @@ spec:
type: string
type: object
clusterType:
description: Type of the deployment that you want to create. The
parameter is required if replicationSpecs are set or if Global
Deployments are deployed.
enum:
- REPLICASET
- SHARDED
- GEOSHARDED
type: string
customZoneMapping:
items:
Expand All @@ -85,10 +95,26 @@ spec:
type: object
type: array
diskSizeGB:
description: Capacity, in gigabytes, of the host's root volume.
Increase this number to add capacity, up to a maximum possible
value of 4096 (i.e., 4 TB). This value must be a positive integer.
The parameter is required if replicationSpecs are configured.
maximum: 4096
minimum: 0
type: integer
encryptionAtRestProvider:
description: Cloud service provider that offers Encryption at
Rest.
enum:
- AWS
- GCP
- AZURE
- NONE
type: string
labels:
description: Collection of key-value pairs that tag and categorize
the deployment. Each key and value has a maximum length of 255
characters.
items:
description: LabelSpec contains key-value pairs that tag and
categorize the Cluster/DBUser
Expand Down Expand Up @@ -128,6 +154,7 @@ spec:
type: object
type: array
mongoDBMajorVersion:
description: Version of the deployment to deploy.
type: string
mongoDBVersion:
type: string
Expand All @@ -138,10 +165,15 @@ spec:
pattern: ^[a-zA-Z0-9][a-zA-Z0-9-]*$
type: string
paused:
description: Flag that indicates whether the deployment should
be paused.
type: boolean
pitEnabled:
description: Flag that indicates the deployment uses continuous
cloud backups.
type: boolean
replicationSpecs:
description: Configuration for deployment regions.
items:
properties:
numShards:
Expand Down
53 changes: 42 additions & 11 deletions pkg/api/v1/atlasdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,51 @@ type AtlasDeploymentSpec struct {
// }

type AdvancedDeploymentSpec struct {
BackupEnabled *bool `json:"backupEnabled,omitempty"`
BiConnector *BiConnectorSpec `json:"biConnector,omitempty"`
ClusterType string `json:"clusterType,omitempty"`
DiskSizeGB *int `json:"diskSizeGB,omitempty"`
EncryptionAtRestProvider string `json:"encryptionAtRestProvider,omitempty"`
Labels []common.LabelSpec `json:"labels,omitempty"`
MongoDBMajorVersion string `json:"mongoDBMajorVersion,omitempty"`
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
// Applicable only for M10+ deployments.
// Flag that indicates if the deployment uses Cloud Backups for backups.
// +optional
BackupEnabled *bool `json:"backupEnabled,omitempty"`
// Configuration of BI Connector for Atlas on this deployment.
// The MongoDB Connector for Business Intelligence for Atlas (BI Connector) is only available for M10 and larger deployments.
// +optional
BiConnector *BiConnectorSpec `json:"biConnector,omitempty"`
// Type of the deployment that you want to create.
// The parameter is required if replicationSpecs are set or if Global Deployments are deployed.
// +kubebuilder:validation:Enum=REPLICASET;SHARDED;GEOSHARDED
// +optional
ClusterType string `json:"clusterType,omitempty"`
// Capacity, in gigabytes, of the host's root volume.
// Increase this number to add capacity, up to a maximum possible value of 4096 (i.e., 4 TB).
// This value must be a positive integer.
// The parameter is required if replicationSpecs are configured.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=4096
// +optional
DiskSizeGB *int `json:"diskSizeGB,omitempty"`
// Cloud service provider that offers Encryption at Rest.
// +kubebuilder:validation:Enum=AWS;GCP;AZURE;NONE
// +optional
EncryptionAtRestProvider string `json:"encryptionAtRestProvider,omitempty"`
// Collection of key-value pairs that tag and categorize the deployment.
// Each key and value has a maximum length of 255 characters.
// +optional
Labels []common.LabelSpec `json:"labels,omitempty"`
// Version of the deployment to deploy.
MongoDBMajorVersion string `json:"mongoDBMajorVersion,omitempty"`
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
// Name of the advanced deployment as it appears in Atlas.
// After Atlas creates the deployment, you can't change its name.
// Can only contain ASCII letters, numbers, and hyphens.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern:=^[a-zA-Z0-9][a-zA-Z0-9-]*$
Name string `json:"name,omitempty"`
Paused *bool `json:"paused,omitempty"`
PitEnabled *bool `json:"pitEnabled,omitempty"`
Name string `json:"name,omitempty"`
// Flag that indicates whether the deployment should be paused.
Paused *bool `json:"paused,omitempty"`
// Flag that indicates the deployment uses continuous cloud backups.
// +optional
PitEnabled *bool `json:"pitEnabled,omitempty"`
// Configuration for deployment regions.
// +optional
ReplicationSpecs []*AdvancedReplicationSpec `json:"replicationSpecs,omitempty"`
RootCertType string `json:"rootCertType,omitempty"`
// Key-value pairs for resource tagging.
Expand Down Expand Up @@ -771,6 +801,7 @@ func (c *AtlasDeployment) WithProjectName(projectName string) *AtlasDeployment {
func (c *AtlasDeployment) WithProviderName(name provider.ProviderName) *AtlasDeployment {
addReplicaIfNotAdded(c)
c.Spec.DeploymentSpec.ReplicationSpecs[0].RegionConfigs[0].ProviderName = string(name)
c.Spec.DeploymentSpec.ReplicationSpecs[0].RegionConfigs[0].BackingProviderName = string(name)
return c
}

Expand Down
4 changes: 2 additions & 2 deletions test/int/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment", "deployment-

Describe("Create/Update the cluster", func() {
It("Should fail, then be fixed (GCP)", func() {
createdDeployment = mdbv1.DefaultGCPDeployment(namespace.Name, createdProject.Name).WithAtlasName("")
createdDeployment = mdbv1.DefaultGCPDeployment(namespace.Name, createdProject.Name).WithAtlasName("----")

By(fmt.Sprintf("Trying to create the Deployment %s with invalid parameters", kube.ObjectKeyFromObject(createdDeployment)), func() {
err := k8sClient.Create(context.Background(), createdDeployment)
Expand All @@ -571,7 +571,7 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment", "deployment-
})
})

It("Should succeed (AWS) with enabled autoscaling", func() {
It("Should succeed (AWS) with enabled autoscaling for Disk size", func() {
createdDeployment = mdbv1.DefaultAWSDeployment(namespace.Name, createdProject.Name)

createdDeployment.Spec.DeploymentSpec.DiskSizeGB = toptr.MakePtr[int](20)
Expand Down

0 comments on commit a8b1b38

Please sign in to comment.