Skip to content

Commit 47d4474

Browse files
chrisstnat-henderson
authored andcommitted
Merge pull request #2430 from modular-magician/codegen-pr-882
Fix ci tests
1 parent c0ddb1b commit 47d4474

7 files changed

+45
-106
lines changed

google/resource_composer_environment_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import (
44
"fmt"
55
"testing"
66

7+
"log"
8+
"strings"
9+
"time"
10+
711
"github.com/hashicorp/go-multierror"
812
"github.com/hashicorp/terraform/helper/acctest"
913
"github.com/hashicorp/terraform/helper/resource"
1014
"github.com/hashicorp/terraform/terraform"
1115
"google.golang.org/api/composer/v1"
1216
"google.golang.org/api/storage/v1"
13-
"log"
14-
"strings"
15-
"time"
1617
)
1718

1819
const testComposerEnvironmentPrefix = "tf-cc-testenv"
@@ -274,6 +275,7 @@ resource "google_composer_environment" "test" {
274275
node_config {
275276
network = "${google_compute_network.test.self_link}"
276277
subnetwork = "${google_compute_subnetwork.test.self_link}"
278+
zone = "us-central1-a"
277279
278280
service_account = "${google_service_account.test.name}"
279281
}

google/resource_compute_firewall_test.go

-95
Original file line numberDiff line numberDiff line change
@@ -283,66 +283,6 @@ func TestAccComputeFirewall_disabled(t *testing.T) {
283283
})
284284
}
285285

286-
func TestAccComputeFirewall_enableLogging(t *testing.T) {
287-
t.Parallel()
288-
289-
var firewall computeBeta.Firewall
290-
networkName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
291-
firewallName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
292-
293-
resource.Test(t, resource.TestCase{
294-
PreCheck: func() { testAccPreCheck(t) },
295-
Providers: testAccProviders,
296-
CheckDestroy: testAccCheckComputeFirewallDestroy,
297-
Steps: []resource.TestStep{
298-
{
299-
Config: testAccComputeFirewall_enableLogging(networkName, firewallName, false),
300-
Check: resource.ComposeTestCheckFunc(
301-
testAccCheckComputeBetaFirewallExists("google_compute_firewall.foobar", &firewall),
302-
testAccCheckComputeFirewallLoggingEnabled(&firewall, false),
303-
),
304-
},
305-
{
306-
ResourceName: "google_compute_firewall.foobar",
307-
ImportState: true,
308-
ImportStateVerify: true,
309-
},
310-
{
311-
Config: testAccComputeFirewall_enableLogging(networkName, firewallName, true),
312-
Check: resource.ComposeTestCheckFunc(
313-
testAccCheckComputeBetaFirewallExists("google_compute_firewall.foobar", &firewall),
314-
testAccCheckComputeFirewallLoggingEnabled(&firewall, true),
315-
),
316-
},
317-
{
318-
Config: testAccComputeFirewall_enableLogging(networkName, firewallName, false),
319-
Check: resource.ComposeTestCheckFunc(
320-
testAccCheckComputeBetaFirewallExists("google_compute_firewall.foobar", &firewall),
321-
testAccCheckComputeFirewallLoggingEnabled(&firewall, false),
322-
),
323-
},
324-
},
325-
})
326-
}
327-
328-
func testAccCheckComputeFirewallDestroy(s *terraform.State) error {
329-
config := testAccProvider.Meta().(*Config)
330-
331-
for _, rs := range s.RootModule().Resources {
332-
if rs.Type != "google_compute_firewall" {
333-
continue
334-
}
335-
336-
_, err := config.clientCompute.Firewalls.Get(
337-
config.Project, rs.Primary.ID).Do()
338-
if err == nil {
339-
return fmt.Errorf("Firewall still exists")
340-
}
341-
}
342-
343-
return nil
344-
}
345-
346286
func testAccCheckComputeFirewallExists(n string, firewall *compute.Firewall) resource.TestCheckFunc {
347287
return func(s *terraform.State) error {
348288
rs, ok := s.RootModule().Resources[n]
@@ -486,15 +426,6 @@ func testAccCheckComputeFirewallApiVersion(firewall *compute.Firewall) resource.
486426
}
487427
}
488428

489-
func testAccCheckComputeFirewallLoggingEnabled(firewall *computeBeta.Firewall, enabled bool) resource.TestCheckFunc {
490-
return func(s *terraform.State) error {
491-
if firewall == nil || firewall.EnableLogging != enabled {
492-
return fmt.Errorf("expected firewall enable_logging to be %t, got %t", enabled, firewall.EnableLogging)
493-
}
494-
return nil
495-
}
496-
}
497-
498429
func testAccComputeFirewall_basic(network, firewall string) string {
499430
return fmt.Sprintf(`
500431
resource "google_compute_network" "foobar" {
@@ -669,29 +600,3 @@ func testAccComputeFirewall_disabled(network, firewall string) string {
669600
disabled = true
670601
}`, network, firewall)
671602
}
672-
673-
func testAccComputeFirewall_enableLogging(network, firewall string, enableLogging bool) string {
674-
enableLoggingCfg := ""
675-
if enableLogging {
676-
enableLoggingCfg = "enable_logging= true"
677-
}
678-
return fmt.Sprintf(`
679-
resource "google_compute_network" "foobar" {
680-
name = "%s"
681-
auto_create_subnetworks = false
682-
ipv4_range = "10.0.0.0/16"
683-
}
684-
685-
resource "google_compute_firewall" "foobar" {
686-
name = "firewall-test-%s"
687-
description = "Resource created for Terraform acceptance testing"
688-
network = "${google_compute_network.foobar.name}"
689-
source_tags = ["foo"]
690-
691-
allow {
692-
protocol = "icmp"
693-
}
694-
695-
%s
696-
}`, network, firewall, enableLoggingCfg)
697-
}

google/resource_compute_project_metadata_item.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package google
33
import (
44
"fmt"
55
"log"
6+
"time"
67

78
"github.com/hashicorp/terraform/helper/schema"
89
"google.golang.org/api/compute/v1"
@@ -35,6 +36,12 @@ func resourceComputeProjectMetadataItem() *schema.Resource {
3536
ForceNew: true,
3637
},
3738
},
39+
40+
Timeouts: &schema.ResourceTimeout{
41+
Create: schema.DefaultTimeout(5 * time.Minute),
42+
Update: schema.DefaultTimeout(5 * time.Minute),
43+
Delete: schema.DefaultTimeout(5 * time.Minute),
44+
},
3845
}
3946
}
4047

@@ -49,7 +56,7 @@ func resourceComputeProjectMetadataItemCreate(d *schema.ResourceData, meta inter
4956
key := d.Get("key").(string)
5057
val := d.Get("value").(string)
5158

52-
err = updateComputeCommonInstanceMetadata(config, projectID, key, &val)
59+
err = updateComputeCommonInstanceMetadata(config, projectID, key, &val, int(d.Timeout(schema.TimeoutCreate).Minutes()))
5360
if err != nil {
5461
return err
5562
}
@@ -101,7 +108,7 @@ func resourceComputeProjectMetadataItemUpdate(d *schema.ResourceData, meta inter
101108
_, n := d.GetChange("value")
102109
new := n.(string)
103110

104-
err = updateComputeCommonInstanceMetadata(config, projectID, key, &new)
111+
err = updateComputeCommonInstanceMetadata(config, projectID, key, &new, int(d.Timeout(schema.TimeoutUpdate).Minutes()))
105112
if err != nil {
106113
return err
107114
}
@@ -119,7 +126,7 @@ func resourceComputeProjectMetadataItemDelete(d *schema.ResourceData, meta inter
119126

120127
key := d.Get("key").(string)
121128

122-
err = updateComputeCommonInstanceMetadata(config, projectID, key, nil)
129+
err = updateComputeCommonInstanceMetadata(config, projectID, key, nil, int(d.Timeout(schema.TimeoutDelete).Minutes()))
123130
if err != nil {
124131
return err
125132
}
@@ -128,7 +135,7 @@ func resourceComputeProjectMetadataItemDelete(d *schema.ResourceData, meta inter
128135
return nil
129136
}
130137

131-
func updateComputeCommonInstanceMetadata(config *Config, projectID string, key string, afterVal *string) error {
138+
func updateComputeCommonInstanceMetadata(config *Config, projectID string, key string, afterVal *string, timeout int) error {
132139
updateMD := func() error {
133140
log.Printf("[DEBUG] Loading project metadata: %s", projectID)
134141
project, err := config.clientCompute.Projects.Get(projectID).Do()
@@ -173,7 +180,7 @@ func updateComputeCommonInstanceMetadata(config *Config, projectID string, key s
173180

174181
log.Printf("[DEBUG] SetCommonInstanceMetadata: %d (%s)", op.Id, op.SelfLink)
175182

176-
return computeOperationWait(config.clientCompute, op, project.Name, "SetCommonInstanceMetadata")
183+
return computeOperationWaitTime(config.clientCompute, op, project.Name, "SetCommonInstanceMetadata", timeout)
177184
}
178185

179186
return MetadataRetryWrapper(updateMD)

google/resource_compute_snapshot.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ func resourceComputeSnapshot() *schema.Resource {
9191
},
9292
},
9393
Timeouts: &schema.ResourceTimeout{
94-
Create: schema.DefaultTimeout(4 * time.Minute),
95-
Update: schema.DefaultTimeout(4 * time.Minute),
96-
Delete: schema.DefaultTimeout(4 * time.Minute),
94+
Create: schema.DefaultTimeout(5 * time.Minute),
95+
Update: schema.DefaultTimeout(5 * time.Minute),
96+
Delete: schema.DefaultTimeout(5 * time.Minute),
9797
},
9898
}
9999
}

google/resource_dataproc_job.go

+7
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ func resourceDataprocJobCreate(d *schema.ResourceData, meta interface{}) error {
251251
}
252252
d.SetId(job.Reference.JobId)
253253

254+
timeoutInMinutes := int(d.Timeout(schema.TimeoutCreate).Minutes())
255+
waitErr := dataprocJobOperationWait(config, region, project, job.Reference.JobId,
256+
"Creating Dataproc job", timeoutInMinutes, 1)
257+
if waitErr != nil {
258+
return waitErr
259+
}
260+
254261
log.Printf("[INFO] Dataproc job %s has been submitted", job.Reference.JobId)
255262
return resourceDataprocJobRead(d, meta)
256263
}

website/docs/r/compute_project_metadata_item.html.markdown

+9
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,12 @@ Project metadata items can be imported using the `key`, e.g.
4646
```
4747
$ terraform import google_compute_project_metadata_item.default my_metadata
4848
```
49+
50+
## Timeouts
51+
52+
This resource provides the following
53+
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
54+
55+
- `create` - Default is 5 minutes.
56+
- `update` - Default is 5 minutes.
57+
- `delete` - Default is 5 minutes.

website/docs/r/compute_snapshot.html.markdown

+9
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,12 @@ exported:
7575
* `self_link` - The URI of the created resource.
7676

7777
* `label_fingerprint` - The unique fingerprint of the labels.
78+
79+
## Timeouts
80+
81+
This resource provides the following
82+
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
83+
84+
- `create` - Default is 5 minutes.
85+
- `update` - Default is 5 minutes.
86+
- `delete` - Default is 5 minutes.

0 commit comments

Comments
 (0)