mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Ci test fixes (#2925)
<!-- This change is generated by MagicModules. --> /cc @chrisst
This commit is contained in:
parent
a464c5e6e1
commit
6779f4dbf4
@ -239,6 +239,7 @@ func TestAccCloudFunctionsFunction_sourceRepo(t *testing.T) {
|
|||||||
|
|
||||||
funcResourceName := "google_cloudfunctions_function.function"
|
funcResourceName := "google_cloudfunctions_function.function"
|
||||||
functionName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
functionName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||||
|
proj := getTestProjectFromEnv()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
@ -246,7 +247,7 @@ func TestAccCloudFunctionsFunction_sourceRepo(t *testing.T) {
|
|||||||
CheckDestroy: testAccCheckCloudFunctionsFunctionDestroy,
|
CheckDestroy: testAccCheckCloudFunctionsFunctionDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCloudFunctionsFunction_sourceRepo(functionName),
|
Config: testAccCloudFunctionsFunction_sourceRepo(functionName, proj),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: funcResourceName,
|
ResourceName: funcResourceName,
|
||||||
@ -588,7 +589,7 @@ resource "google_cloudfunctions_function" "function" {
|
|||||||
}`, bucketName, zipFilePath, functionName)
|
}`, bucketName, zipFilePath, functionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCloudFunctionsFunction_sourceRepo(functionName string) string {
|
func testAccCloudFunctionsFunction_sourceRepo(functionName, project string) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
resource "google_cloudfunctions_function" "function" {
|
resource "google_cloudfunctions_function" "function" {
|
||||||
name = "%s"
|
name = "%s"
|
||||||
@ -596,13 +597,13 @@ resource "google_cloudfunctions_function" "function" {
|
|||||||
source_repository {
|
source_repository {
|
||||||
// There isn't yet an API that'll allow us to create a source repository and
|
// There isn't yet an API that'll allow us to create a source repository and
|
||||||
// put code in it, so we created this repository outside the test to be used
|
// put code in it, so we created this repository outside the test to be used
|
||||||
// here. If this test is run outside of CI, it may fail because of permissions
|
// here. If this test is run outside of CI, you may need to create your own
|
||||||
// errors.
|
// source repo.
|
||||||
url = "https://source.developers.google.com/projects/hc-terraform-testing/repos/cloudfunctions-test-do-not-delete/moveable-aliases/master/paths/"
|
url = "https://source.developers.google.com/projects/%s/repos/cloudfunctions-test-do-not-delete/moveable-aliases/master/paths/"
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger_http = true
|
trigger_http = true
|
||||||
entry_point = "helloGET"
|
entry_point = "helloGET"
|
||||||
}
|
}
|
||||||
`, functionName)
|
`, functionName, project)
|
||||||
}
|
}
|
||||||
|
@ -223,9 +223,9 @@ func suppressWindowsSqlFamilyDiff(imageName, familyName string) bool {
|
|||||||
// e.g. image: windows-server-1709-dc-core-for-containers-v20180109, family: "windows-1709-core-for-containers
|
// e.g. image: windows-server-1709-dc-core-for-containers-v20180109, family: "windows-1709-core-for-containers
|
||||||
func suppressWindowsFamilyDiff(imageName, familyName string) bool {
|
func suppressWindowsFamilyDiff(imageName, familyName string) bool {
|
||||||
updatedFamilyString := strings.Replace(familyName, "windows-", "windows-server-", 1)
|
updatedFamilyString := strings.Replace(familyName, "windows-", "windows-server-", 1)
|
||||||
updatedFamilyString = strings.Replace(updatedFamilyString, "-core", "-dc-core", 1)
|
updatedImageName := strings.Replace(imageName, "-dc-", "-", 1)
|
||||||
|
|
||||||
if strings.Contains(imageName, updatedFamilyString) {
|
if strings.Contains(updatedImageName, updatedFamilyString) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +218,13 @@ func migrateStateV3toV4(is *terraform.InstanceState, meta interface{}) (*terrafo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disks, err := strconv.Atoi(is.Attributes["disk.#"])
|
disks := 0
|
||||||
|
if v := is.Attributes["disk.#"]; v != "" {
|
||||||
|
disks, err = strconv.Atoi(is.Attributes["disk.#"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return is, fmt.Errorf("migration error: found disk.# value in unexpected format: %s", err)
|
return is, fmt.Errorf("migration error: found disk.# value in unexpected format: %s", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < disks; i++ {
|
for i := 0; i < disks; i++ {
|
||||||
if !hasBootDisk && i == 0 {
|
if !hasBootDisk && i == 0 {
|
||||||
@ -320,7 +323,11 @@ func getInstanceFromInstanceState(config *Config, is *terraform.InstanceState) (
|
|||||||
|
|
||||||
zone, ok := is.Attributes["zone"]
|
zone, ok := is.Attributes["zone"]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if config.Zone == "" {
|
||||||
return nil, fmt.Errorf("could not determine 'zone'")
|
return nil, fmt.Errorf("could not determine 'zone'")
|
||||||
|
} else {
|
||||||
|
zone = config.Zone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance, err := config.clientCompute.Instances.Get(
|
instance, err := config.clientCompute.Instances.Get(
|
||||||
@ -344,7 +351,11 @@ func getAllDisksFromInstanceState(config *Config, is *terraform.InstanceState) (
|
|||||||
|
|
||||||
zone, ok := is.Attributes["zone"]
|
zone, ok := is.Attributes["zone"]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if config.Zone == "" {
|
||||||
return nil, fmt.Errorf("could not determine 'zone'")
|
return nil, fmt.Errorf("could not determine 'zone'")
|
||||||
|
} else {
|
||||||
|
zone = config.Zone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diskList := []*compute.Disk{}
|
diskList := []*compute.Disk{}
|
||||||
|
@ -25,12 +25,14 @@ func TestComputeInstanceMigrateState(t *testing.T) {
|
|||||||
"v0.4.2 and earlier": {
|
"v0.4.2 and earlier": {
|
||||||
StateVersion: 0,
|
StateVersion: 0,
|
||||||
Attributes: map[string]string{
|
Attributes: map[string]string{
|
||||||
|
"disk.#": "0",
|
||||||
"metadata.#": "2",
|
"metadata.#": "2",
|
||||||
"metadata.0.foo": "bar",
|
"metadata.0.foo": "bar",
|
||||||
"metadata.1.baz": "qux",
|
"metadata.1.baz": "qux",
|
||||||
"metadata.2.with.dots": "should.work",
|
"metadata.2.with.dots": "should.work",
|
||||||
},
|
},
|
||||||
Expected: map[string]string{
|
Expected: map[string]string{
|
||||||
|
"create_timeout": "4",
|
||||||
"metadata.foo": "bar",
|
"metadata.foo": "bar",
|
||||||
"metadata.baz": "qux",
|
"metadata.baz": "qux",
|
||||||
"metadata.with.dots": "should.work",
|
"metadata.with.dots": "should.work",
|
||||||
@ -77,8 +79,37 @@ func TestComputeInstanceMigrateState(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config := getInitializedConfig(t)
|
config := getInitializedConfig(t)
|
||||||
|
|
||||||
|
instanceName := fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||||
|
instance := &compute.Instance{
|
||||||
|
Name: instanceName,
|
||||||
|
Disks: []*compute.AttachedDisk{
|
||||||
|
{
|
||||||
|
Boot: true,
|
||||||
|
InitializeParams: &compute.AttachedDiskInitializeParams{
|
||||||
|
SourceImage: "projects/debian-cloud/global/images/family/debian-9",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MachineType: "zones/" + config.Zone + "/machineTypes/n1-standard-1",
|
||||||
|
NetworkInterfaces: []*compute.NetworkInterface{
|
||||||
|
{
|
||||||
|
Network: "global/networks/default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
op, err := config.clientCompute.Instances.Insert(config.Project, config.Zone, instance).Do()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error creating instance: %s", err)
|
||||||
|
}
|
||||||
|
waitErr := computeSharedOperationWait(config.clientCompute, op, config.Project, "instance to create")
|
||||||
|
if waitErr != nil {
|
||||||
|
t.Fatal(waitErr)
|
||||||
|
}
|
||||||
|
defer cleanUpInstance(config, instanceName, config.Zone)
|
||||||
|
|
||||||
for tn, tc := range cases {
|
for tn, tc := range cases {
|
||||||
runInstanceMigrateTest(t, "i-abc123", tn, tc.StateVersion, tc.Attributes, tc.Expected, config)
|
runInstanceMigrateTest(t, instanceName, tn, tc.StateVersion, tc.Attributes, tc.Expected, config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,6 +899,7 @@ func getInitializedConfig(t *testing.T) *Config {
|
|||||||
Project: getTestProjectFromEnv(),
|
Project: getTestProjectFromEnv(),
|
||||||
Credentials: getTestCredsFromEnv(),
|
Credentials: getTestCredsFromEnv(),
|
||||||
Region: getTestRegionFromEnv(),
|
Region: getTestRegionFromEnv(),
|
||||||
|
Zone: getTestZoneFromEnv(),
|
||||||
}
|
}
|
||||||
err := config.loadAndValidate()
|
err := config.loadAndValidate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -870,7 +870,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
|
|||||||
machine_type = "n1-standard-1"
|
machine_type = "n1-standard-1"
|
||||||
disk_config {
|
disk_config {
|
||||||
boot_disk_type = "pd-standard"
|
boot_disk_type = "pd-standard"
|
||||||
boot_disk_size_gb = 11
|
boot_disk_size_gb = 16
|
||||||
num_local_ssds = 1
|
num_local_ssds = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,7 +879,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
|
|||||||
num_instances = 1
|
num_instances = 1
|
||||||
disk_config {
|
disk_config {
|
||||||
boot_disk_type = "pd-ssd"
|
boot_disk_type = "pd-ssd"
|
||||||
boot_disk_size_gb = 12
|
boot_disk_size_gb = 17
|
||||||
num_local_ssds = 1
|
num_local_ssds = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,12 +608,12 @@ func testAccDataprocJob_hadoop(rnd string) string {
|
|||||||
args = [
|
args = [
|
||||||
"wordcount",
|
"wordcount",
|
||||||
"file:///usr/lib/spark/NOTICE",
|
"file:///usr/lib/spark/NOTICE",
|
||||||
"gs://${google_dataproc_cluster.basic.cluster_config.0.bucket}/hadoopjob_output"
|
"gs://${google_dataproc_cluster.basic.cluster_config.0.bucket}/hadoopjob_output_%s"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
`, rnd)
|
`, rnd, rnd)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,11 @@ func testGoogleSqlClientCert_postgres(instance string) string {
|
|||||||
settings {
|
settings {
|
||||||
tier = "db-f1-micro"
|
tier = "db-f1-micro"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeouts {
|
||||||
|
create = "20m"
|
||||||
|
delete = "20m"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_sql_ssl_cert" "cert" {
|
resource "google_sql_ssl_cert" "cert" {
|
||||||
|
Loading…
Reference in New Issue
Block a user