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

Added column server_configurations in azure_mysql_server table. Closes #427 #429

Merged
merged 6 commits into from
Jan 5, 2022

Conversation

bigdatasourav
Copy link
Contributor

@bigdatasourav bigdatasourav commented Dec 29, 2021

Integration test logs

Logs
SETUP: tests/azure_mysql_server []

PRETEST: tests/azure_mysql_server

TEST: tests/azure_mysql_server
Running terraform

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_mysql_server.named_test_resource will be created
  + resource "azurerm_mysql_server" "named_test_resource" {
      + administrator_login               = "mradministrator"
      + administrator_login_password      = (sensitive value)
      + auto_grow_enabled                 = false
      + backup_retention_days             = 7
      + create_mode                       = "Default"
      + fqdn                              = (known after apply)
      + geo_redundant_backup_enabled      = false
      + id                                = (known after apply)
      + infrastructure_encryption_enabled = false
      + location                          = "eastus"
      + name                              = "turbottest10163"
      + public_network_access_enabled     = true
      + resource_group_name               = "turbottest10163"
      + sku_name                          = "B_Gen5_2"
      + ssl_enforcement                   = (known after apply)
      + ssl_enforcement_enabled           = true
      + ssl_minimal_tls_version_enforced  = "TLS1_2"
      + storage_mb                        = 5120
      + tags                              = {
          + "name" = "turbottest10163"
        }
      + version                           = "5.7"

      + storage_profile {
          + auto_grow             = (known after apply)
          + backup_retention_days = (known after apply)
          + geo_redundant_backup  = (known after apply)
          + storage_mb            = (known after apply)
        }
    }

  # azurerm_resource_group.named_test_resource will be created
  + resource "azurerm_resource_group" "named_test_resource" {
      + id       = (known after apply)
      + location = "eastus"
      + name     = "turbottest10163"
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + location           = "eastus"
  + resource_aka       = (known after apply)
  + resource_aka_lower = (known after apply)
  + resource_id        = (known after apply)
  + resource_name      = "turbottest10163"
  + server_fqdn        = (known after apply)
  + subscription_id    = "d46d7416-f95f-4771-bbb5-529d4c76659c"
azurerm_resource_group.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Creation complete after 3s [id=/subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbottest10163]
azurerm_mysql_server.named_test_resource: Creating...
azurerm_mysql_server.named_test_resource: Still creating... [10s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [20s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [30s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [40s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [50s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [1m0s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [1m10s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [1m20s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [1m30s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [1m40s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [1m50s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [2m0s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [2m10s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [2m20s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [2m30s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [2m40s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [2m50s elapsed]
azurerm_mysql_server.named_test_resource: Still creating... [3m0s elapsed]
azurerm_mysql_server.named_test_resource: Creation complete after 3m8s [id=/subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbottest10163/providers/Microsoft.DBforMySQL/servers/turbottest10163]

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

Outputs:

location = "eastus"
resource_aka = "azure:///subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbottest10163/providers/Microsoft.DBforMySQL/servers/turbottest10163"
resource_aka_lower = "azure:///subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourcegroups/turbottest10163/providers/microsoft.dbformysql/servers/turbottest10163"
resource_id = "/subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbottest10163/providers/Microsoft.DBforMySQL/servers/turbottest10163"
resource_name = "turbottest10163"
server_fqdn = "turbottest10163.mysql.database.azure.com"
subscription_id = "d46d7416-f95f-4771-bbb5-529d4c76659c"

Running SQL query: test-get-query.sql
[
  {
    "administrator_login": "mradministrator",
    "backup_retention_days": 7,
    "fully_qualified_domain_name": "turbottest10163.mysql.database.azure.com",
    "geo_redundant_backup": "Disabled",
    "infrastructure_encryption": "Disabled",
    "location": "eastus",
    "minimal_tls_version": "TLS1_2",
    "name": "turbottest10163",
    "public_network_access": "Enabled",
    "region": "eastus",
    "resource_group": "turbottest10163",
    "sku_capacity": 2,
    "sku_family": "Gen5",
    "sku_name": "B_Gen5_2",
    "sku_tier": "Basic",
    "ssl_enforcement": "Enabled",
    "storage_auto_grow": "Disabled",
    "storage_mb": 5120,
    "subscription_id": "d46d7416-f95f-4771-bbb5-529d4c76659c",
    "type": "Microsoft.DBforMySQL/servers",
    "version": "5.7"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "id": "/subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbottest10163/providers/Microsoft.DBforMySQL/servers/turbottest10163",
    "location": "eastus",
    "name": "turbottest10163"
  }
]
✔ PASSED

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

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "azure:///subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbottest10163/providers/Microsoft.DBforMySQL/servers/turbottest10163",
      "azure:///subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourcegroups/turbottest10163/providers/microsoft.dbformysql/servers/turbottest10163"
    ],
    "name": "turbottest10163",
    "tags": {
      "name": "turbottest10163"
    },
    "title": "turbottest10163"
  }
]
✔ PASSED

POSTTEST: tests/azure_mysql_server

TEARDOWN: tests/azure_mysql_server

SUMMARY:

1/1 passed.

Example query results

Results
> select
  name as server_name,
  id as server_id,
  configurations ->> 'Name' as configuration_name,
  configurations -> 'ConfigurationProperties' ->> 'value' as value
from
  azure_mysql_server,
  jsonb_array_elements(server_configurations) as configurations
where 
   configurations ->'ConfigurationProperties' ->> 'value' = 'OFF'
   and configurations ->> 'Name' = 'audit_log_enabled';
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
| server_name | server_id                                                                                                                 | configuration_name | value |
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
| qwewq       | /subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbot_rg/providers/Microsoft.DBforMySQL/servers/qwewq | audit_log_enabled  | OFF   |
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+

> select
  name as server_name,
  id as server_id,
  configurations ->> 'Name' as configuration_name,
  configurations -> 'ConfigurationProperties' ->> 'value' as value
from
  azure_mysql_server,
  jsonb_array_elements(server_configurations) as configurations
where 
   configurations ->> 'Name' = 'slow_query_log';
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
| server_name | server_id                                                                                                                 | configuration_name | value |
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
| qwewq       | /subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbot_rg/providers/Microsoft.DBforMySQL/servers/qwewq | slow_query_log     | OFF   |
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
> select
  name as server_name,
  id as server_id,
  configurations ->> 'Name' as configuration_name,
  configurations -> 'ConfigurationProperties' ->> 'value' as value
from
  azure_mysql_server,
  jsonb_array_elements(server_configurations) as configurations
where 
   configurations ->> 'Name' = 'log_output';
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
| server_name | server_id                                                                                                                 | configuration_name | value |
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+
| qwewq       | /subscriptions/d46d7416-f95f-4771-bbb5-529d4c76659c/resourceGroups/turbot_rg/providers/Microsoft.DBforMySQL/servers/qwewq | log_output         | FILE  |
+-------------+---------------------------------------------------------------------------------------------------------------------------+--------------------+-------+

@bigdatasourav bigdatasourav self-assigned this Dec 29, 2021
@bigdatasourav bigdatasourav linked an issue Dec 29, 2021 that may be closed by this pull request
bigdatasourav added 2 commits December 29, 2021 17:14
@@ -191,6 +191,13 @@ func tableAzureMySQLServer(_ context.Context) *plugin.Table {
Type: proto.ColumnType_JSON,
Transform: transform.From(extractMySQLServerPrivateEndpointConnections),
},
{
Name: "server_configurations",
Copy link
Contributor

Choose a reason for hiding this comment

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

will it be Server parameters? as per this azure doc

name as server_name,
id as server_id,
configurations ->> 'name' as configuration_name,
configurations -> 'ConfigurationProperties' ->> 'value' as value
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
configurations -> 'ConfigurationProperties' ->> 'value' as value
configurations -> 'configurationProperties' ->> 'value' as value

@@ -118,3 +118,64 @@ from
azure_mysql_server,
jsonb_array_elements(server_keys) as keys;
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a simple example stating the current value of the properties.

 select
  name as server_name,
  id as server_id,
  configurations ->> 'name' as configuration_name,
  configurations -> 'configurationProperties' ->> 'value' as value
from
  azure_mysql_server,
  jsonb_array_elements(server_configurations) as configurations
where 
   configurations ->> 'name' = 'slow_query_log';

@@ -118,3 +118,63 @@ from
azure_mysql_server,
jsonb_array_elements(server_keys) as keys;
```

### List server configuration details
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: Server configurations is the same as Server parameters as shown in Azure MySQL server console

bigdatasourav added 2 commits January 4, 2022 19:47
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 f9a78d6 into main Jan 5, 2022
@bigdatasourav bigdatasourav deleted the issue-427 branch January 5, 2022 06:15
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.

Azure MySQL Server parameters request
2 participants