-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Issue #459 - EBS information required during cluster config change #1131
Changes from all commits
b0a8352
40a82fe
7071e77
268a455
eaa9795
d94f173
b24b01a
53ccd7c
700bb88
9a41771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,54 @@ func TestAccAWSElasticSearchDomain_tags(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSElasticSearchDomain_update(t *testing.T) { | ||
var input elasticsearch.ElasticsearchDomainStatus | ||
ri := acctest.RandInt() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckESDomainDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccESDomainConfig_ClusterUpdate(ri, 2, 22), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckESDomainExists("aws_elasticsearch_domain.example", &input), | ||
testAccCheckESNumberOfInstances(2, &input), | ||
testAccCheckESSnapshotHour(22, &input), | ||
), | ||
}, | ||
{ | ||
Config: testAccESDomainConfig_ClusterUpdate(ri, 4, 23), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckESDomainExists("aws_elasticsearch_domain.example", &input), | ||
testAccCheckESNumberOfInstances(4, &input), | ||
testAccCheckESSnapshotHour(23, &input), | ||
), | ||
}, | ||
}}) | ||
} | ||
|
||
func testAccCheckESSnapshotHour(snapshotHour int, status *elasticsearch.ElasticsearchDomainStatus) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
conf := status.SnapshotOptions | ||
if *conf.AutomatedSnapshotStartHour != int64(snapshotHour) { | ||
return fmt.Errorf("Snapshots start hour differ. Given: %d, Expected: %d", *conf.AutomatedSnapshotStartHour, snapshotHour) | ||
} | ||
return nil | ||
} | ||
} | ||
|
||
func testAccCheckESNumberOfInstances(numberOfInstances int, status *elasticsearch.ElasticsearchDomainStatus) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
conf := status.ElasticsearchClusterConfig | ||
if *conf.InstanceCount != int64(numberOfInstances) { | ||
return fmt.Errorf("Number of instances differ. Given: %d, Expected: %d", *conf.InstanceCount, numberOfInstances) | ||
} | ||
return nil | ||
} | ||
} | ||
|
||
func testAccLoadESTags(conf *elasticsearch.ElasticsearchDomainStatus, td *elasticsearch.ListTagsOutput) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
conn := testAccProvider.Meta().(*AWSClient).esconn | ||
|
@@ -224,6 +272,34 @@ resource "aws_elasticsearch_domain" "example" { | |
`, randInt) | ||
} | ||
|
||
func testAccESDomainConfig_ClusterUpdate(randInt, instanceInt, snapshotInt int) string { | ||
return fmt.Sprintf(` | ||
resource "aws_elasticsearch_domain" "example" { | ||
domain_name = "tf-test-%d" | ||
|
||
advanced_options { | ||
"indices.fielddata.cache.size" = 80 | ||
} | ||
|
||
ebs_options { | ||
ebs_enabled = true | ||
volume_size = 10 | ||
|
||
} | ||
|
||
cluster_config { | ||
instance_count = %d | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be certainly static number, we don't want to be spinning up an unbound random number of instances 💸 😃 Randomization is however certainly desired, but only in places that are unique, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I've also changed instance type to |
||
zone_awareness_enabled = true | ||
instance_type = "t2.micro.elasticsearch" | ||
} | ||
|
||
snapshot_options { | ||
automated_snapshot_start_hour = %d | ||
} | ||
} | ||
`, randInt, instanceInt, snapshotInt) | ||
} | ||
|
||
func testAccESDomainConfig_TagUpdate(randInt int) string { | ||
return fmt.Sprintf(` | ||
resource "aws_elasticsearch_domain" "example" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is the reason for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is purely cosmetic. In case where there is an error, function will
return
from function so there is no need to keepelse
. From other side, by using 'else' we can show that there is a relation betweensetTagsElasticsearchService
andd.SetPartial("tags")
, so if there is any relation between them maybe we should keepelse
:>btw. In documentation there is no
else
block -https://www.terraform.io/docs/plugins/provider.htmlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right, good point. Early return FTW 👍