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/iplb/testaccs #144

Merged
merged 8 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
## 0.8.0 (Unreleased)

FEATURES:

* __New Datasource:__ `ovh_me_ipxe_script` ([#141](https://github.com/terraform-providers/terraform-provider-ovh/pull/141))
* __New Datasource:__ `ovh_me_ipxe_scripts` ([#141](https://github.com/terraform-providers/terraform-provider-ovh/pull/141))
* __New Resource:__ `ovh_me_ipxe_script` ([#141](https://github.com/terraform-providers/terraform-provider-ovh/pull/141))

IMPROVEMENTS:

* Stop failing sweepers if mandatory env vars are missing. ([#142](https://github.com/terraform-providers/terraform-provider-ovh/pull/142))
* r/iploadbalancing_*: Add importers and tests([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))
* r/iploadbalancing_tcp_farm, r/iploadbalancing_http_farm: Extend read function to get all values ([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))
* r/iploadbalancing_http_route: Extend read function to get action value ([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))
* r/iploadbalancing_http_route_rule: Read all values ([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))
* r/iploadbalancing_tcp_frontend, r/iploadbalancing_http_frontend: Some code refactoring according to linter ([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))

BUG FIXES:

* r/iploadbalancing_vrack_network: fix sweepers ([#142](https://github.com/terraform-providers/terraform-provider-ovh/pull/142))
* r/iploadbalancing_tcp_farm, r/iploadbalancing_http_farm: Fix typo in 'oco' probe type ([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))
* r/iploadbalancing_tcp_farm_server, r/iploadbalancing_http_farm_server: Allow port to have a nil value ([#140](https://github.com/terraform-providers/terraform-provider-ovh/pull/140))

## 0.7.0 (March 02, 2020)

FEATURES:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-ovh
require (
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/terraform-plugin-sdk v1.0.0
github.com/hashicorp/terraform-plugin-sdk v1.12.0
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014
Expand Down
200 changes: 27 additions & 173 deletions go.sum

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions ovh/data_source_ovh_iploadbalancing_vrack_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@ func dataSourceIpLoadbalancingVrackNetwork() *schema.Resource {
},

//Computed
"farm_id": {
Type: schema.TypeList,
Description: "Farm id your vRack network is attached to and their type",
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"display_name": {
Type: schema.TypeString,
Description: "Human readable name for your vrack network",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestAccIpLoadbalancingVrackNetworkDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.ovh_iploadbalancing_vrack_network.network", "vlan", testAccIpLoadbalancingVrackNetworkVlan1001),
resource.TestCheckResourceAttrSet("data.ovh_iploadbalancing_vrack_network.network", "id"),
resource.TestCheckResourceAttr("data.ovh_iploadbalancing_vrack_network.network", "nat_ip", testAccIpLoadbalancingVrackNetworkNatIp),
resource.TestCheckResourceAttrSet("data.ovh_iploadbalancing_vrack_network.network", "farm_id.#"),
),
},
},
Expand Down
8 changes: 4 additions & 4 deletions ovh/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func validateFilesystem(value string) error {

func getNilBoolPointerFromData(data interface{}, id string) *bool {
if resourceData, tok := data.(*schema.ResourceData); tok {
if val, ok := resourceData.GetOkExists(id); ok {
if val, ok := resourceData.GetOk(id); ok {
return getNilBoolPointer(val)
}
} else if mapData, tok := data.(map[string]interface{}); tok {
Expand All @@ -166,7 +166,7 @@ func getNilBoolPointerFromData(data interface{}, id string) *bool {

func getNilStringPointerFromData(data interface{}, id string) *string {
if resourceData, tok := data.(*schema.ResourceData); tok {
if val, ok := resourceData.GetOkExists(id); ok {
if val, ok := resourceData.GetOk(id); ok {
return getNilStringPointer(val)
}
} else if mapData, tok := data.(map[string]interface{}); tok {
Expand All @@ -180,7 +180,7 @@ func getNilStringPointerFromData(data interface{}, id string) *string {

func getNilIntPointerFromData(data interface{}, id string) *int {
if resourceData, tok := data.(*schema.ResourceData); tok {
if val, ok := resourceData.GetOkExists(id); ok {
if val, ok := resourceData.GetOk(id); ok {
return getNilIntPointer(val)
}
} else if mapData, tok := data.(map[string]interface{}); tok {
Expand All @@ -194,7 +194,7 @@ func getNilIntPointerFromData(data interface{}, id string) *int {

func getNilInt64PointerFromData(data interface{}, id string) *int64 {
if resourceData, tok := data.(*schema.ResourceData); tok {
if val, ok := resourceData.GetOkExists(id); ok {
if val, ok := resourceData.GetOk(id); ok {
return getNilInt64Pointer(val)
}
} else if mapData, tok := data.(map[string]interface{}); tok {
Expand Down
4 changes: 3 additions & 1 deletion ovh/import_iploadbalancing_http_farm_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func testAccIpLoadbalancingHttpFarmServerImportId(resourceName string) resource.
}
}

var httpServerAddress = "127.0.0.1" //change it to a proper address in OVH network
// an OVH IPv4 is required for servers
// ping.ovh.net ip is used for test purposes
var httpServerAddress = "198.27.92.1"
var testAccIpLoadbalancingHttpFarmServerConfig_basic = fmt.Sprintf(testAccIpLoadbalancingHttpFarmServerConfig,
os.Getenv("OVH_IPLB_SERVICE"), "testfarm", 12345, "all", "testserver", httpServerAddress)
29 changes: 6 additions & 23 deletions ovh/import_iploadbalancing_http_farm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,22 @@ import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

const (
testAccIpLoadbalancingHttpFarmConfig = `
data "ovh_iploadbalancing" "iplb" {
service_name = "%s"
}
resource "ovh_iploadbalancing_http_farm" "testfarm" {
service_name = data.ovh_iploadbalancing.iplb.id
display_name = "%s"
port = "%d"
zone = "%s"
balance = "roundrobin"
probe {
interval = 30
type = "oco"
}
}
`
)

func TestAccIpLoadbalancingHttpFarm_importBasic(t *testing.T) {
displayName := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(testAccIpLoadbalancingHttpFarmConfig,
os.Getenv("OVH_IPLB_SERVICE"), displayName, 12345, "all")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckIpLoadbalancing(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccIpLoadbalancingHttpFarmConfig_basic,
Config: config,
},
{
ResourceName: "ovh_iploadbalancing_http_farm.testfarm",
Expand All @@ -59,6 +45,3 @@ func testAccIpLoadbalancingHttpFarmImportId(resourceName string) resource.Import
), nil
}
}

var testAccIpLoadbalancingHttpFarmConfig_basic = fmt.Sprintf(testAccIpLoadbalancingHttpFarmConfig,
os.Getenv("OVH_IPLB_SERVICE"), "testfarm", 12345, "all")
4 changes: 3 additions & 1 deletion ovh/import_iploadbalancing_tcp_farm_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func testAccIpLoadbalancingTcpFarmServerImportId(resourceName string) resource.I
}
}

var tcpServerAddress = "127.0.0.1" //change it to a proper address in OVH network
// an OVH IPv4 is required for servers
// ping.ovh.net ip is used for test purposes
var tcpServerAddress = "198.27.92.1"
var testAccIpLoadbalancingTcpFarmServerConfig_basic = fmt.Sprintf(testAccIpLoadbalancingTcpFarmServerConfig,
os.Getenv("OVH_IPLB_SERVICE"), "testfarm", 12345, "all", "testserver", tcpServerAddress)
29 changes: 5 additions & 24 deletions ovh/import_iploadbalancing_tcp_farm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,21 @@ import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

const (
testAccIpLoadbalancingTcpFarmConfig = `
data "ovh_iploadbalancing" "iplb" {
service_name = "%s"
}

resource "ovh_iploadbalancing_tcp_farm" "testfarm" {
service_name = data.ovh_iploadbalancing.iplb.id
display_name = "%s"
port = "%d"
zone = "%s"
balance = "roundrobin"
probe {
interval = 30
type = "oco"
}
}
`
)

func TestAccIpLoadbalancingTcpFarm_importBasic(t *testing.T) {
displayName := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(testAccIpLoadbalancingTcpFarmConfig,
os.Getenv("OVH_IPLB_SERVICE"), displayName, 12345, "all")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckIpLoadbalancing(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccIpLoadbalancingTcpFarmConfig_basic,
Config: config,
},
{
ResourceName: "ovh_iploadbalancing_tcp_farm.testfarm",
Expand All @@ -60,6 +44,3 @@ func testAccIpLoadbalancingTcpFarmImportId(resourceName string) resource.ImportS
), nil
}
}

var testAccIpLoadbalancingTcpFarmConfig_basic = fmt.Sprintf(testAccIpLoadbalancingTcpFarmConfig,
os.Getenv("OVH_IPLB_SERVICE"), "testfarm", 12345, "all")
2 changes: 0 additions & 2 deletions ovh/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ func testAccCheckVRackExists(t *testing.T) {
if err != nil {
t.Fatalf("Error: %q\n", err)
}
t.Logf("Read VRack %s -> name:'%s', desc:'%s' ", endpoint, r.Name, r.Description)

}

func testAccCheckCloudExists(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions ovh/resource_ovh_domain_zone_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func testSweepDomainZoneRecord(region string) error {
return nil
}

func TestAccOvhDomainZoneRecord_Basic(t *testing.T) {
func TestAccDomainZoneRecord_Basic(t *testing.T) {
var record OvhDomainZoneRecord
zone := os.Getenv("OVH_ZONE")
subdomain := acctest.RandomWithPrefix(test_prefix)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestAccOvhDomainZoneRecord_Basic(t *testing.T) {
})
}

func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
func TestAccDomainZoneRecord_Updated(t *testing.T) {
record := OvhDomainZoneRecord{}
zone := os.Getenv("OVH_ZONE")
subdomain := acctest.RandomWithPrefix(test_prefix)
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
})
}

func TestAccOvhDomainZoneRecord_updateType(t *testing.T) {
func TestAccDomainZoneRecord_updateType(t *testing.T) {
record := OvhDomainZoneRecord{}
zone := os.Getenv("OVH_ZONE")
subdomain := acctest.RandomWithPrefix(test_prefix)
Expand Down
4 changes: 2 additions & 2 deletions ovh/resource_ovh_domain_zone_redirection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func testSweepDomainZoneRedirection(region string) error {
return nil
}

func TestAccOvhDomainZoneRedirection_Basic(t *testing.T) {
func TestAccDomainZoneRedirection_Basic(t *testing.T) {
var redirection OvhDomainZoneRedirection
zone := os.Getenv("OVH_ZONE")
subdomain := acctest.RandomWithPrefix(test_prefix)
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestAccOvhDomainZoneRedirection_Basic(t *testing.T) {
})
}

func TestAccOvhDomainZoneRedirection_Updated(t *testing.T) {
func TestAccDomainZoneRedirection_Updated(t *testing.T) {
redirection := OvhDomainZoneRedirection{}
zone := os.Getenv("OVH_ZONE")
subdomain := acctest.RandomWithPrefix(test_prefix)
Expand Down
Loading