Skip to content

Commit 2559cbe

Browse files
committed
Add an acctest for engine_version argument
1 parent 461f694 commit 2559cbe

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

internal/service/opensearch/package_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"testing"
1010

11+
awstypes "github.com/aws/aws-sdk-go-v2/service/opensearch/types"
1112
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1213
"github.com/hashicorp/terraform-plugin-testing/terraform"
1314
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
@@ -53,6 +54,43 @@ func TestAccOpenSearchPackage_basic(t *testing.T) {
5354
})
5455
}
5556

57+
func TestAccOpenSearchPackage_packageTypeZipPlugin(t *testing.T) {
58+
ctx := acctest.Context(t)
59+
pkgName := testAccRandomDomainName()
60+
resourceName := "aws_opensearch_package.test"
61+
62+
resource.ParallelTest(t, resource.TestCase{
63+
PreCheck: func() { acctest.PreCheck(ctx, t) },
64+
ErrorCheck: acctest.ErrorCheck(t, names.OpenSearchServiceID),
65+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
66+
CheckDestroy: testAccCheckPackageDestroy(ctx),
67+
Steps: []resource.TestStep{
68+
{
69+
Config: testAccPackageConfig_packageTypeZipPlugin(pkgName, "OpenSearch_2.17"),
70+
Check: resource.ComposeAggregateTestCheckFunc(
71+
testAccCheckPackageExists(ctx, resourceName),
72+
resource.TestCheckResourceAttr(resourceName, "available_package_version", "v1"),
73+
resource.TestCheckResourceAttr(resourceName, "engine_version", "OpenSearch_2.17"),
74+
resource.TestCheckResourceAttr(resourceName, "package_description", ""),
75+
resource.TestCheckResourceAttrSet(resourceName, "package_id"),
76+
resource.TestCheckResourceAttr(resourceName, "package_name", pkgName),
77+
resource.TestCheckResourceAttr(resourceName, "package_source.#", "1"),
78+
resource.TestCheckResourceAttr(resourceName, "package_type", string(awstypes.PackageTypeZipPlugin)),
79+
),
80+
},
81+
{
82+
ResourceName: resourceName,
83+
ImportState: true,
84+
ImportStateVerify: true,
85+
ImportStateVerifyIgnore: []string{
86+
"available_package_version",
87+
"package_source", // This isn't returned by the API
88+
},
89+
},
90+
},
91+
})
92+
}
93+
5694
func TestAccOpenSearchPackage_disappears(t *testing.T) {
5795
ctx := acctest.Context(t)
5896
pkgName := testAccRandomDomainName()
@@ -140,3 +178,35 @@ resource "aws_opensearch_package" "test" {
140178
}
141179
`, rName)
142180
}
181+
182+
func testAccPackageConfig_packageTypeZipPlugin(rName, engineVersion string) string {
183+
return fmt.Sprintf(`
184+
resource "aws_s3_bucket" "test" {
185+
bucket = %[1]q
186+
}
187+
188+
189+
# example-dummy-opensearch-plugin.zip was created from the sample repository provided by AWS using the following commands:
190+
# > git clone https://github.com/aws-samples/kr-tech-blog-sample-code.git
191+
# > cd kr-tech-blog-sample-code/opensearch_custom_plugin
192+
# > gradele build
193+
# > cp build/distributions/opensearch-custom-plugin-1.0.0.zip terraform-provider-aws/internal/service/opensearch/test-fixtures/example-dummy-opensearch-plugin.zip
194+
195+
resource "aws_s3_object" "test" {
196+
bucket = aws_s3_bucket.test.bucket
197+
key = %[1]q
198+
source = "./test-fixtures/example-dummy-opensearch-plugin.zip"
199+
etag = filemd5("./test-fixtures/example-dummy-opensearch-plugin.zip")
200+
}
201+
202+
resource "aws_opensearch_package" "test" {
203+
engine_version = %[2]q
204+
package_name = %[1]q
205+
package_source {
206+
s3_bucket_name = aws_s3_bucket.test.bucket
207+
s3_key = aws_s3_object.test.key
208+
}
209+
package_type = "ZIP-PLUGIN"
210+
}
211+
`, rName, engineVersion)
212+
}
Binary file not shown.

0 commit comments

Comments
 (0)