@@ -2,14 +2,13 @@ package aws
22
33import (
44 "fmt"
5- "math/rand"
65 "strings"
76 "testing"
8- "time"
97
108 "github.com/aws/aws-sdk-go/aws"
119 "github.com/aws/aws-sdk-go/aws/awserr"
1210 "github.com/aws/aws-sdk-go/service/elasticache"
11+ "github.com/hashicorp/terraform/helper/acctest"
1312 "github.com/hashicorp/terraform/helper/resource"
1413 "github.com/hashicorp/terraform/terraform"
1514)
@@ -37,7 +36,7 @@ func TestAccAWSElasticacheCluster_basic(t *testing.T) {
3736func TestAccAWSElasticacheCluster_snapshotsWithUpdates (t * testing.T ) {
3837 var ec elasticache.CacheCluster
3938
40- ri := genRandInt ()
39+ ri := acctest . RandInt ()
4140 preConfig := fmt .Sprintf (testAccAWSElasticacheClusterConfig_snapshots , ri , ri , ri )
4241 postConfig := fmt .Sprintf (testAccAWSElasticacheClusterConfig_snapshotsUpdated , ri , ri , ri )
4342
@@ -76,7 +75,7 @@ func TestAccAWSElasticacheCluster_snapshotsWithUpdates(t *testing.T) {
7675func TestAccAWSElasticacheCluster_decreasingCacheNodes (t * testing.T ) {
7776 var ec elasticache.CacheCluster
7877
79- ri := genRandInt ()
78+ ri := acctest . RandInt ()
8079 preConfig := fmt .Sprintf (testAccAWSElasticacheClusterConfigDecreasingNodes , ri , ri , ri )
8180 postConfig := fmt .Sprintf (testAccAWSElasticacheClusterConfigDecreasingNodes_update , ri , ri , ri )
8281
@@ -218,10 +217,6 @@ func testAccCheckAWSElasticacheClusterExists(n string, v *elasticache.CacheClust
218217 }
219218}
220219
221- func genRandInt () int {
222- return rand .New (rand .NewSource (time .Now ().UnixNano ())).Int () % 1000
223- }
224-
225220var testAccAWSElasticacheClusterConfig = fmt .Sprintf (`
226221provider "aws" {
227222 region = "us-east-1"
@@ -244,15 +239,15 @@ resource "aws_elasticache_security_group" "bar" {
244239}
245240
246241resource "aws_elasticache_cluster" "bar" {
247- cluster_id = "tf-test-%03d "
242+ cluster_id = "tf-%s "
248243 engine = "memcached"
249244 node_type = "cache.m1.small"
250245 num_cache_nodes = 1
251246 port = 11211
252247 parameter_group_name = "default.memcached1.4"
253248 security_group_names = ["${aws_elasticache_security_group.bar.name}"]
254249}
255- ` , genRandInt (), genRandInt (), genRandInt ( ))
250+ ` , acctest . RandInt (), acctest . RandInt (), acctest . RandString ( 10 ))
256251
257252var testAccAWSElasticacheClusterConfig_snapshots = `
258253provider "aws" {
@@ -276,7 +271,7 @@ resource "aws_elasticache_security_group" "bar" {
276271}
277272
278273resource "aws_elasticache_cluster" "bar" {
279- cluster_id = "tf-test- %03d"
274+ cluster_id = "tf-%03d"
280275 engine = "redis"
281276 node_type = "cache.m1.small"
282277 num_cache_nodes = 1
@@ -310,7 +305,7 @@ resource "aws_elasticache_security_group" "bar" {
310305}
311306
312307resource "aws_elasticache_cluster" "bar" {
313- cluster_id = "tf-test- %03d"
308+ cluster_id = "tf-%03d"
314309 engine = "redis"
315310 node_type = "cache.m1.small"
316311 num_cache_nodes = 1
@@ -345,7 +340,7 @@ resource "aws_elasticache_security_group" "bar" {
345340}
346341
347342resource "aws_elasticache_cluster" "bar" {
348- cluster_id = "tf-test- %03d"
343+ cluster_id = "tf-%03d"
349344 engine = "memcached"
350345 node_type = "cache.m1.small"
351346 num_cache_nodes = 3
@@ -377,7 +372,7 @@ resource "aws_elasticache_security_group" "bar" {
377372}
378373
379374resource "aws_elasticache_cluster" "bar" {
380- cluster_id = "tf-test- %03d"
375+ cluster_id = "tf-%03d"
381376 engine = "memcached"
382377 node_type = "cache.m1.small"
383378 num_cache_nodes = 1
@@ -427,7 +422,7 @@ resource "aws_elasticache_cluster" "bar" {
427422 // Including uppercase letters in this name to ensure
428423 // that we correctly handle the fact that the API
429424 // normalizes names to lowercase.
430- cluster_id = "tf-TEST-%03d "
425+ cluster_id = "tf-%s "
431426 node_type = "cache.m1.small"
432427 num_cache_nodes = 1
433428 engine = "redis"
@@ -443,7 +438,7 @@ resource "aws_elasticache_cluster" "bar" {
443438resource "aws_sns_topic" "topic_example" {
444439 name = "tf-ecache-cluster-test"
445440}
446- ` , genRandInt (), genRandInt (), genRandInt ( ))
441+ ` , acctest . RandInt (), acctest . RandInt (), acctest . RandString ( 10 ))
447442
448443var testAccAWSElasticacheClusterMultiAZInVPCConfig = fmt .Sprintf (`
449444resource "aws_vpc" "foo" {
@@ -493,7 +488,7 @@ resource "aws_security_group" "bar" {
493488}
494489
495490resource "aws_elasticache_cluster" "bar" {
496- cluster_id = "tf-test-%03d "
491+ cluster_id = "tf-%s "
497492 engine = "memcached"
498493 node_type = "cache.m1.small"
499494 num_cache_nodes = 2
@@ -507,4 +502,4 @@ resource "aws_elasticache_cluster" "bar" {
507502 "us-west-2b"
508503 ]
509504}
510- ` , genRandInt (), genRandInt (), genRandInt (), genRandInt (), genRandInt ( ))
505+ ` , acctest . RandInt (), acctest . RandInt (), acctest . RandInt (), acctest . RandInt (), acctest . RandString ( 10 ))
0 commit comments