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

Add Long Term Retention Policies details in table azure_sql_database closes #219 #255

Merged
merged 9 commits into from
Aug 12, 2021

Conversation

ParthaI
Copy link
Contributor

@ParthaI ParthaI commented Aug 11, 2021

Integration test logs

Logs
No env file present for the current environment:  staging 
 Falling back to .env config
No env file present for the current environment:  staging
customEnv TURBOT_TEST_EXPECTED_TIMEOUT undefined

SETUP: tests/azure_sql_database []

PRETEST: tests/azure_sql_database

TEST: tests/azure_sql_database
Running terraform
data.azurerm_client_config.current: Refreshing state...
data.null_data_source.resource: Refreshing state...
azurerm_resource_group.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Creation complete after 2s [id=/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097]
azurerm_sql_server.named_test_resource: Creating...
azurerm_sql_server.named_test_resource: Still creating... [10s elapsed]
azurerm_sql_server.named_test_resource: Still creating... [20s elapsed]
azurerm_sql_server.named_test_resource: Still creating... [30s elapsed]
azurerm_sql_server.named_test_resource: Still creating... [40s elapsed]
azurerm_sql_server.named_test_resource: Still creating... [50s elapsed]
azurerm_sql_server.named_test_resource: Still creating... [1m0s elapsed]
azurerm_sql_server.named_test_resource: Still creating... [1m10s elapsed]
azurerm_sql_server.named_test_resource: Creation complete after 1m17s [id=/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097]
azurerm_sql_database.named_test_resource: Creating...
azurerm_sql_database.named_test_resource: Still creating... [10s elapsed]
azurerm_sql_database.named_test_resource: Still creating... [20s elapsed]
azurerm_sql_database.named_test_resource: Still creating... [30s elapsed]
azurerm_sql_database.named_test_resource: Still creating... [40s elapsed]
azurerm_sql_database.named_test_resource: Still creating... [50s elapsed]
azurerm_sql_database.named_test_resource: Still creating... [1m0s elapsed]
azurerm_sql_database.named_test_resource: Still creating... [1m10s elapsed]
azurerm_sql_database.named_test_resource: Creation complete after 1m12s [id=/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097]

Warning: Deprecated Resource

The null_data_source was historically used to construct intermediate values to
re-use elsewhere in configuration, the same can now be achieved using locals


Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Outputs:

resource_aka = azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097
resource_aka_lower = azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourcegroups/turbottest33097/providers/microsoft.sql/servers/turbottest33097/databases/turbottest33097
resource_creation_date = 2021-08-11T11:11:27.893Z
resource_default_secondary_location = West US
resource_id = /subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097
resource_location = East US
resource_name = turbottest33097
resource_region = east us
subscription_id = d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8

Running SQL query: test-get-query.sql
[
  {
    "akas": [
      "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097",
      "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourcegroups/turbottest33097/providers/microsoft.sql/servers/turbottest33097/databases/turbottest33097"
    ],
    "containment_state": 2,
    "default_secondary_location": "West US",
    "earliest_restore_date": null,
    "edition": "GeneralPurpose",
    "elastic_pool_name": null,
    "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097",
    "location": "East US",
    "max_size_bytes": "34359738368",
    "name": "turbottest33097",
    "region": "east us",
    "requested_service_objective_name": "GP_Gen5_2",
    "resource_group": "turbottest33097",
    "server_name": "turbottest33097",
    "service_level_objective": "GP_Gen5_2",
    "status": "Online",
    "subscription_id": "d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8",
    "tags": {
      "foo": "bar"
    },
    "title": "turbottest33097",
    "transparent_data_encryption": {
      "status": "Enabled"
    },
    "type": "Microsoft.Sql/servers/databases",
    "zone_redundant": false
  }
]
✔ PASSED

Running SQL query: test-hydrate-query.sql
[
  {
    "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097",
    "name": "turbottest33097",
    "server_name": "turbottest33097",
    "transparent_data_encryption": {
      "status": "Enabled"
    }
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097",
    "location": "East US",
    "name": "turbottest33097",
    "resource_group": "turbottest33097",
    "server_name": "turbottest33097"
  }
]
✔ PASSED

Running SQL query: test-not-found-query.sql
null
✔ PASSED

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbottest33097/providers/Microsoft.Sql/servers/turbottest33097/databases/turbottest33097",
      "azure:///subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourcegroups/turbottest33097/providers/microsoft.sql/servers/turbottest33097/databases/turbottest33097"
    ],
    "name": "turbottest33097",
    "tags": {
      "foo": "bar"
    },
    "title": "turbottest33097"
  }
]
✔ PASSED

POSTTEST: tests/azure_sql_database

TEARDOWN: tests/azure_sql_database

SUMMARY:

1/1 passed.

Example query results

Results
select name, server_name, retention_policy_id, retention_policy_name, retention_policy_type, retention_policy_property from azure_sql_database;
+--------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------------------------------------------------------------+----------------------------------------------------------------------------------------------+
| name   | server_name | retention_policy_id                                                                                                                                                            | retention_policy_name | retention_policy_type                                           | retention_policy_property                                                                    |
+--------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------------------------------------------------------------+----------------------------------------------------------------------------------------------+
| master | turbot-db   | <null>                                                                                                                                                                         | <null>                | <null>                                                          | <null>                                                                                       |
| my-db  | turbot-db   | /subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbot_rg/providers/Microsoft.Sql/servers/turbot-db/databases/my-db/backupLongTermRetentionPolicies/default | default               | Microsoft.Sql/servers/databases/backupLongTermRetentionPolicies | {"monthlyRetention":"PT0S","weekOfYear":0,"weeklyRetention":"PT0S","yearlyRetention":"PT0S"} |
+--------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------------------------------------------------------------+----------------------------------------------------------------------------------------------+

@ParthaI ParthaI requested a review from khushboo9024 August 11, 2021 11:15
@ParthaI ParthaI self-assigned this Aug 11, 2021
@ParthaI ParthaI linked an issue Aug 11, 2021 that may be closed by this pull request
Name: "retention_policy_property",
Description: "Long term Retention policy Property.",
Type: proto.ColumnType_JSON,
Hydrate: getSqlDatabaseLongTermRetentionPolicies,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordering of columns is not proper, please check.

database := h.Item.(sql.Database)
serverName = strings.Split(*database.ID, "/")[8]
databaseName = *database.Name
plugin.Logger(ctx).Trace("Hydrate Database Id", *database.ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Copy link
Contributor

@rajlearner17 rajlearner17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bigdatasourav bigdatasourav merged commit 081dae3 into main Aug 12, 2021
@bigdatasourav bigdatasourav deleted the issue-219 branch August 12, 2021 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Long Term Retention Policies details in table azure_sql_database
4 participants