mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 17:16:44 +00:00
139 lines
3.4 KiB
Go
139 lines
3.4 KiB
Go
// ----------------------------------------------------------------------------
|
|
//
|
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// This file is automatically generated by Magic Modules and manual
|
|
// changes will be clobbered when the file is regenerated.
|
|
//
|
|
// Please read more about how to change this file in
|
|
// .github/CONTRIBUTING.md.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
|
|
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpExample(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckMonitoringUptimeCheckConfigDestroy,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpExample(acctest.RandString(10)),
|
|
},
|
|
{
|
|
ResourceName: "google_monitoring_uptime_check_config.http",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpExample(val string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_monitoring_uptime_check_config" "http" {
|
|
display_name = "http-uptime-check-%s"
|
|
timeout = "60s"
|
|
|
|
http_check = {
|
|
path = "/some-path"
|
|
port = "8010"
|
|
}
|
|
|
|
monitored_resource {
|
|
type = "uptime_url"
|
|
labels = {
|
|
project_id = "example"
|
|
host = "192.168.1.1"
|
|
}
|
|
}
|
|
|
|
content_matchers = {
|
|
content = "example"
|
|
}
|
|
}
|
|
`, val,
|
|
)
|
|
}
|
|
|
|
func TestAccMonitoringUptimeCheckConfig_uptimeCheckTcpExample(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckMonitoringUptimeCheckConfigDestroy,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccMonitoringUptimeCheckConfig_uptimeCheckTcpExample(acctest.RandString(10)),
|
|
},
|
|
{
|
|
ResourceName: "google_monitoring_uptime_check_config.tcp_group",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccMonitoringUptimeCheckConfig_uptimeCheckTcpExample(val string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_monitoring_uptime_check_config" "tcp_group" {
|
|
display_name = "tcp-uptime-check-%s"
|
|
timeout = "60s"
|
|
|
|
tcp_check = {
|
|
port = 888
|
|
}
|
|
|
|
resource_group {
|
|
resource_type = "INSTANCE"
|
|
group_id = "${google_monitoring_group.check.name}"
|
|
}
|
|
}
|
|
|
|
|
|
resource "google_monitoring_group" "check" {
|
|
display_name = "uptime-check-group-%s"
|
|
filter = "resource.metadata.name=has_substring(\"foo\")"
|
|
}
|
|
`, val, val,
|
|
)
|
|
}
|
|
|
|
func testAccCheckMonitoringUptimeCheckConfigDestroy(s *terraform.State) error {
|
|
for _, rs := range s.RootModule().Resources {
|
|
if rs.Type != "google_monitoring_uptime_check_config" {
|
|
continue
|
|
}
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
|
|
url, err := replaceVarsForTest(rs, "https://monitoring.googleapis.com/v3/{{name}}")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = sendRequest(config, "GET", url, nil)
|
|
if err == nil {
|
|
return fmt.Errorf("MonitoringUptimeCheckConfig still exists at %s", url)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|