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

fix: Connection and secret-datasource tests #3177

Merged
merged 10 commits into from
Nov 8, 2024

Conversation

sfc-gh-fbudzynski
Copy link
Collaborator

Changes

  • fix secrets datasource acceptance tests
  • added tests for ParseCommaSeparatedAccountIdentifierArray
  • added customDiff and tests for re-creating connection resources
  • adjusted migration-guide and documentation for connection resources
  • added 'TestAccPreCheck' to acceptance tests

Test Plan

  • unit tests
  • integration tests
  • acceptance tests
  • acceptance tests for secrets-datasource

References

Copy link

github-actions bot commented Nov 7, 2024

Integration tests failure for 509846ce74244475a8bdabb25b36125c020923b7

MIGRATION_GUIDE.md Show resolved Hide resolved
templates/resources/primary_connection.md.tmpl Outdated Show resolved Hide resolved
{
Name: "list without brackets",
Value: "A.B, C.D",
Result: []AccountIdentifier{NewAccountIdentifier("A", "B"), NewAccountIdentifier("C", "D")},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add some cases to test non-nil errors.

Copy link
Collaborator

@sfc-gh-jcieslak sfc-gh-jcieslak Nov 8, 2024

Choose a reason for hiding this comment

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

Should be addressed in the next pr.
cc @sfc-gh-fbudzynski

pkg/resources/primary_connection.go Outdated Show resolved Hide resolved
@@ -216,11 +216,14 @@ func TestAcc_Secrets_WithGenericString(t *testing.T) {
})
}

func secretsData(secretResourceName string) string {
func secretsData(secretResourceName string, inDatabaseName string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I think it should be an account object identifier and FullyQualifiedName should be inside this func.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be addressed in the next pr (if needed).
cc @sfc-gh-fbudzynski

Copy link
Collaborator Author

@sfc-gh-fbudzynski sfc-gh-fbudzynski Nov 12, 2024

Choose a reason for hiding this comment

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

we can pass the secret identifier (which is a schemaObjectIdentifier) and use secretId.DatabaseId().FullyQualifiedName() inside the function and secretModel to retrieve the resource name

sfc-gh-asawicki
sfc-gh-asawicki previously approved these changes Nov 8, 2024
---

!> **V1 release candidate** This resource is a release candidate for the V1. It is on the list of remaining GA objects for V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0970--v0980) to use it.

# snowflake_primary_connection (Resource)

Resource used to manage primary (not replicated) connections. For more information, check [connection documentation](https://docs.snowflake.com/en/sql-reference/sql/create-connection.html).
Resource used to manage primary connections. For managing replicated connection check resource [snowflake_secondary_connection](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/resources/secondary_connection.md). For more information, check [connection documentation](https://docs.snowflake.com/en/sql-reference/sql/create-connection.html).
Copy link
Collaborator

Choose a reason for hiding this comment

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

these paths should be relative instead of absolute (the given version of the provider should point to the given version) - example e.g. in the deprecated_resources.md

In all other places in this PR too


-> **Note** To demote [`snowflake_primary_connection`](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/primary_connection) to [`snowflake_secondary_connection`](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/secondary_connection), resources need to be migrated manually. For guidance on removing and importing resources into the state check [resource migration](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/resource_migration.md). Remove the resource from the state, then recreate it in manually using:
```
CREATE CONNECTION <name> AS REPLICA OF <organization_name>.<account_name>.<connection_name>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: in such blocks, MD formatting is a bit different, and this gets inlined. This is fine; I just write for future reference.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I checked in https://registry.terraform.io/tools/doc-preview and this is how you can include more than one line in the note block

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, strange. I checked the docs/issues some time ago and it was not possible to have newlines in these notes/warnings.

Copy link
Collaborator

Choose a reason for hiding this comment

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

From: https://developer.hashicorp.com/terraform/registry/providers/docs#callouts, You can't make multi-paragraph callouts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@sfc-gh-jcieslak sfc-gh-jcieslak force-pushed the fix-connection-resource branch from 1511db1 to 1251438 Compare November 8, 2024 13:18
Copy link

github-actions bot commented Nov 8, 2024

Integration tests cancelled for 12514387187e113e858d9e8f12753f47a26b3038

Copy link

github-actions bot commented Nov 8, 2024

Integration tests failure for 1eb98166a435cf0acccc6c7fddea004b4b16c76f

@sfc-gh-asawicki sfc-gh-asawicki self-requested a review November 8, 2024 13:30

-> **Note** To demote [`snowflake_primary_connection`](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/primary_connection) to [`snowflake_secondary_connection`](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/secondary_connection), resources need to be migrated manually. For guidance on removing and importing resources into the state check [resource migration](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/resource_migration.md). Remove the resource from the state, then recreate it in manually using:
-> **Note** To demote [`snowflake_primary_connection`](./primary_connection) to [`snowflake_secondary_connection`](./secondary_connection), resources need to be migrated manually. For guidance on removing and importing resources into the state check [resource migration](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/resource_migration.md). Remove the resource from the state, then recreate it in manually using:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit (for later): do we need a self reference here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I dont think the selfreference is needed, the reference to complementary resource would be enough. My thoughts only tho

@@ -28,9 +28,9 @@ resource "snowflake_secondary_connection" "complete" {
}
```

-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources).
-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](../guides/identifiers#new-computed-fully-qualified-name-field-in-resources).
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure if this one will be correct

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's 404.


-> **Note** To demote [`snowflake_primary_connection`](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/primary_connection) to [`snowflake_secondary_connection`](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/secondary_connection), resources need to be migrated manually. For guidance on removing and importing resources into the state check [resource migration](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/resource_migration.md). Remove the resource from the state, then recreate it in manually using:
```
CREATE CONNECTION <name> AS REPLICA OF <organization_name>.<account_name>.<connection_name>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, strange. I checked the docs/issues some time ago and it was not possible to have newlines in these notes/warnings.

Copy link

github-actions bot commented Nov 8, 2024

Integration tests failure for 1511db144f4fd3a063c8f0c90d9e6664063b2fc8

@sfc-gh-jcieslak sfc-gh-jcieslak merged commit 167de4b into main Nov 8, 2024
8 of 9 checks passed
@sfc-gh-jcieslak sfc-gh-jcieslak deleted the fix-connection-resource branch November 8, 2024 15:10
sfc-gh-jmichalak pushed a commit that referenced this pull request Nov 8, 2024
##
[0.98.0](v0.97.0...v0.98.0)
(2024-11-08)

Feature scope readiness for V1:
[link](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/ESSENTIAL_GA_OBJECTS.MD)
([Roadmap
reference](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#wrap-up-the-functional-scope)).
:exclamation: Migration guide: [v0.97.0 ->
v0.98.0](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0970--v0980)

### 🎉 What's new
- New resources:
- authentication_policy
([#3098](#3098)),
references
[#2880](#2880)
- external_volume
([#3106](#3106)),
partially references
[#2980](#2980)
- stream_on_directory_table
([#3129](#3129))
- stream_on_view
([#3150](#3150))
- primary_connection, secondary_connection
([#3162](#3162))
- secret_with_basic_authentication, secret_with_generic_string,
secret_with_oauth_authorization_code_grant,
secret_with_oauth_client_credentials
([#3110](#3110)),
([#3141](#3141))
- New data sources:
- connections
([#3155](#3155)),
([#3173](#3173))
- secrets
([#3131](#3131))
- Reworked:
- provider configuration hierarchy
([#3166](#3166)),
references
[#1881](#1881),
[#2145](#2145),
[#2925](#2925),
[#2983](#2983),
[#3104](#3104)
- provider configuration fields
([#3152](#3152))
streams data source
([#3151](#3151))
- SDK upgrades:
- Upgrade tag SDK
([#3126](#3126))
- Recreate streams when they are stale
([#3129](#3129))
### 🔧  Misc
- Add object renaming research summary
([#3172](#3172))
- Test support for object renaming
([#3130](#3130)),
([#3147](#3147)),
([#3154](#3154))
- Add tests to issue
[#3117](#3117)
([#3133](#3133))
- New roadmap entry
([#3158](#3158))
- Test more authentication methods
([#3178](#3178))
- Minor fixes
([#3174](#3174))
### 🐛  Bug fixes
- Apply various fixes
([#3176](#3176)),
this addresses BCR 2024_08, references
[#2717](#2717),
[#3005](#3005),
[#3125](#3125),
[#3127](#3127),
[#3153](#3153)
- Connection and secret data sources tests
([#3177](#3177))
- Fix grant import docs
([#3183](#3183)),
resolves
[#3179](https://github.com/Snowflake-Labs/terraform-provider-snowflake/discussions/3179)
- Fix user resource import
([#3181](#3181))
- Handle external type changes in stream resources
([#3164](#3164))
- Do not use OR REPLACE on initial creation in resources with
copy_grants
([#3129](#3129))
- Address issue
[#2201](#2201)
by introducing new stream resources

Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
sfc-gh-fbudzynski added a commit that referenced this pull request Nov 14, 2024
<!-- Feel free to delete comments as you fill this in -->

<!-- summary of changes -->
## Changes
* added `../` to `primary_connection` documentation 
* added invalid test cases for
`ParseCommaSeparatedAccountIdentifierArray`
* changed `secretsData()` function parameters

## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested
-->
* [x] acceptance tests for secrets
* [x] unit tests for parser 

## References
<!-- issues documentation links, etc  -->
references to comments:
*
#3177 (comment)
*
#3177 (comment)
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.

4 participants