Skip to content

Commit

Permalink
unit and integration tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
abodhekar committed Nov 2, 2023
1 parent 7ad72f6 commit a99652d
Show file tree
Hide file tree
Showing 11 changed files with 5,421 additions and 38 deletions.
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

145 changes: 127 additions & 18 deletions config/crd/bases/persistance.atlas.infoblox.com_databaseclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ spec:
status:
description: DatabaseClaimStatus defines the observed state of DatabaseClaim
properties:
oldDB:
description: track the status of the old db which is migrated and non operational
activeDB:
description: track the status of the active db being used by the application
properties:
DbState:
description: DbState of the DB. inprogress, "", ready
Expand All @@ -257,20 +257,128 @@ spec:
userName:
type: string
type: object
type:
description: Specifies the type of database to provision. Only
postgres is supported.
connectionUpdatedAt:
description: Time the connection info was updated/created.
format: date-time
type: string
postMigrationActionStartedAt:
description: Time the process of post migration actions have started
dbCreateAt:
description: Time the database was created
format: date-time
type: string
dbversion:
description: Version of the provisioned Database
type: string
matchLabel:
description: The name of the label that was successfully matched
against the fragment key names in the db-controller configMap
type: string
minStorageGB:
description: The optional MinStorageGB value requests the minimum
database host storage capacity in GBytes
type: integer
postMigrationActionStartedAt:
description: Time at the process of post migration actions initiated
format: date-time
type: string
shape:
description: The optional Shape values are arbitrary and help
drive instance selection
type: string
sourceDataFrom:
description: SourceDataFrom specifies an existing database or
backup to use when initially provisioning the database. if the
dbclaim has already provisioned a database, this field is ignored
This field used when claim is use-existing-db and attempting
to migrate to newdb
properties:
database:
description: Database defines the connection information to
an existing db
properties:
dsn:
description: 'DSN is the connection string used to reach
the postgres database must have protocol specifier at
beginning (example: mysql:// postgres:// )'
type: string
secretRef:
description: 'SecretRef specifies a secret to use for
connecting to the postgresdb (should be master/root)
TODO: document/validate the secret format required'
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
required:
- dsn
type: object
s3:
description: S3 defines the location of a DB backup in an
S3 bucket
properties:
bucket:
type: string
prefix:
description: Prefix is the path prefix of the S3 bucket
within which the backup to restore is located.
type: string
region:
type: string
secretRef:
description: 'SecretRef specifies a secret to use for
connecting to the s3 bucket via AWS client TODO: document/validate
the secret format required'
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
sourceEngine:
description: SourceEngine is the engine used to create
the backup.
type: string
sourceEngineVersion:
description: 'SourceEngineVersion is the version of the
engine used to create the backup. Example: "5.7.30"'
type: string
required:
- bucket
- region
- sourceEngine
- sourceEngineVersion
type: object
type:
description: Type specifies the type of source
type: string
required:
- type
type: object
type:
description: Specifies the type of database to provision. Only
postgres is supported.
type: string
userUpdatedAt:
description: Time the user/password was updated/created
format: date-time
type: string
required:
- connectionInfo
type: object
activeDB:
description: track the status of the active db being used by the application
error:
description: Any errors related to provisioning this claim.
type: string
migrationState:
description: tracks status of DB migration. if empty, not started.
non empty denotes migration in progress, unless it is S_Completed
type: string
newDB:
description: track the status of new db in the process of being created
properties:
DbState:
description: DbState of the DB. inprogress, "", ready
Expand Down Expand Up @@ -309,6 +417,10 @@ spec:
description: The optional MinStorageGB value requests the minimum
database host storage capacity in GBytes
type: integer
postMigrationActionStartedAt:
description: Time at the process of post migration actions initiated
format: date-time
type: string
shape:
description: The optional Shape values are arbitrary and help
drive instance selection
Expand Down Expand Up @@ -399,15 +511,8 @@ spec:
required:
- connectionInfo
type: object
error:
description: Any errors related to provisioning this claim.
type: string
migrationState:
description: tracks status of DB migration. if empty, not started.
non empty denotes migration in progress, unless it is S_Completed
type: string
newDB:
description: track the status of new db in the process of being created
oldDB:
description: tracks the DB which is migrated and not more operational
properties:
DbState:
description: DbState of the DB. inprogress, "", ready
Expand Down Expand Up @@ -446,6 +551,10 @@ spec:
description: The optional MinStorageGB value requests the minimum
database host storage capacity in GBytes
type: integer
postMigrationActionStartedAt:
description: Time at the process of post migration actions initiated
format: date-time
type: string
shape:
description: The optional Shape values are arbitrary and help
drive instance selection
Expand Down
2 changes: 1 addition & 1 deletion controllers/databaseclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (r *DatabaseClaimReconciler) getMode(dbClaim *persistancev1.DatabaseClaim)
//default mode is M_UseNewDB. any non supported combination needs to be identfied and set to M_NotSupported

if dbClaim.Status.OldDB.DbState == persistancev1.PostMigrationInProgress {
if dbClaim.Status.OldDB.ConnectionInfo == nil || dbClaim.Status.ActiveDB.DbState != persistancev1.Ready || *dbClaim.Status.NewDB.ConnectionInfo != (persistancev1.DatabaseClaimConnectionInfo{}) ||
if dbClaim.Status.OldDB.ConnectionInfo == nil || dbClaim.Status.ActiveDB.DbState != persistancev1.Ready ||
r.Input.SharedDBHost || *dbClaim.Spec.UseExistingSource || dbClaim.Spec.SourceDataFrom != nil {
return M_NotSupported
}
Expand Down
Loading

0 comments on commit a99652d

Please sign in to comment.