github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/ultradns/resource_ultradns_tcpool_test.go (about)

     1  package ultradns
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/Ensighten/udnssdk"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccUltradnsTcpool(t *testing.T) {
    12  	var record udnssdk.RRSet
    13  	domain := "ultradns.phinze.com"
    14  
    15  	resource.Test(t, resource.TestCase{
    16  		PreCheck:     func() { testAccPreCheck(t) },
    17  		Providers:    testAccProviders,
    18  		CheckDestroy: testAccTcpoolCheckDestroy,
    19  		Steps: []resource.TestStep{
    20  			resource.TestStep{
    21  				Config: fmt.Sprintf(testCfgTcpoolMinimal, domain),
    22  				Check: resource.ComposeTestCheckFunc(
    23  					testAccCheckUltradnsRecordExists("ultradns_tcpool.it", &record),
    24  					// Specified
    25  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "zone", domain),
    26  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "name", "test-tcpool-minimal"),
    27  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "ttl", "300"),
    28  
    29  					// hashRdatas(): 10.6.0.1 -> 2847814707
    30  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.host", "10.6.0.1"),
    31  					// Defaults
    32  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "act_on_probes", "true"),
    33  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "description", "Minimal TC Pool"),
    34  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "max_to_lb", "0"),
    35  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "run_probes", "true"),
    36  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.failover_delay", "0"),
    37  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.priority", "1"),
    38  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.run_probes", "true"),
    39  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.state", "NORMAL"),
    40  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.threshold", "1"),
    41  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2847814707.weight", "2"),
    42  					// Generated
    43  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "id", "test-tcpool-minimal.ultradns.phinze.com"),
    44  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "hostname", "test-tcpool-minimal.ultradns.phinze.com."),
    45  				),
    46  			},
    47  			resource.TestStep{
    48  				Config: fmt.Sprintf(testCfgTcpoolMaximal, domain),
    49  				Check: resource.ComposeTestCheckFunc(
    50  					testAccCheckUltradnsRecordExists("ultradns_tcpool.it", &record),
    51  					// Specified
    52  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "zone", domain),
    53  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "name", "test-tcpool-maximal"),
    54  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "ttl", "300"),
    55  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "description", "traffic controller pool with all settings tuned"),
    56  
    57  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "act_on_probes", "false"),
    58  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "max_to_lb", "2"),
    59  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "run_probes", "false"),
    60  
    61  					// hashRdatas(): 10.6.1.1 -> 2826722820
    62  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.host", "10.6.1.1"),
    63  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.failover_delay", "30"),
    64  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.priority", "1"),
    65  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.run_probes", "true"),
    66  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.state", "ACTIVE"),
    67  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.threshold", "1"),
    68  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.2826722820.weight", "2"),
    69  
    70  					// hashRdatas(): 10.6.1.2 -> 829755326
    71  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.host", "10.6.1.2"),
    72  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.failover_delay", "30"),
    73  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.priority", "2"),
    74  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.run_probes", "true"),
    75  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.state", "INACTIVE"),
    76  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.threshold", "1"),
    77  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.829755326.weight", "4"),
    78  
    79  					// hashRdatas(): 10.6.1.3 -> 1181892392
    80  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.host", "10.6.1.3"),
    81  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.failover_delay", "30"),
    82  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.priority", "3"),
    83  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.run_probes", "false"),
    84  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.state", "NORMAL"),
    85  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.threshold", "1"),
    86  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "rdata.1181892392.weight", "8"),
    87  					// Generated
    88  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "id", "test-tcpool-maximal.ultradns.phinze.com"),
    89  					resource.TestCheckResourceAttr("ultradns_tcpool.it", "hostname", "test-tcpool-maximal.ultradns.phinze.com."),
    90  				),
    91  			},
    92  		},
    93  	})
    94  }
    95  
    96  const testCfgTcpoolMinimal = `
    97  resource "ultradns_tcpool" "it" {
    98    zone        = "%s"
    99    name        = "test-tcpool-minimal"
   100    ttl         = 300
   101    description = "Minimal TC Pool"
   102  
   103    rdata {
   104      host = "10.6.0.1"
   105    }
   106  }
   107  `
   108  
   109  const testCfgTcpoolMaximal = `
   110  resource "ultradns_tcpool" "it" {
   111    zone        = "%s"
   112    name        = "test-tcpool-maximal"
   113    ttl         = 300
   114    description = "traffic controller pool with all settings tuned"
   115  
   116    act_on_probes = false
   117    max_to_lb     = 2
   118    run_probes    = false
   119  
   120    rdata {
   121      host = "10.6.1.1"
   122  
   123      failover_delay = 30
   124      priority       = 1
   125      run_probes     = true
   126      state          = "ACTIVE"
   127      threshold      = 1
   128      weight         = 2
   129    }
   130  
   131    rdata {
   132      host = "10.6.1.2"
   133  
   134      failover_delay = 30
   135      priority       = 2
   136      run_probes     = true
   137      state          = "INACTIVE"
   138      threshold      = 1
   139      weight         = 4
   140    }
   141  
   142    rdata {
   143      host = "10.6.1.3"
   144  
   145      failover_delay = 30
   146      priority       = 3
   147      run_probes     = false
   148      state          = "NORMAL"
   149      threshold      = 1
   150      weight         = 8
   151    }
   152  
   153    backup_record_rdata          = "10.6.1.4"
   154    backup_record_failover_delay = 30
   155  }
   156  `