Skip to content

Commit 03f91d5

Browse files
authored
[Compute_Disk] - Add beta multi-writer support (#3911)
* [Compute_Disk] - Add beta multi-writer support: * set machine type to n2 for testcase... not supported for n1 * migrate test to disk resource
1 parent 9fc9098 commit 03f91d5

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

products/compute/api.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,6 +3274,11 @@ objects:
32743274
resource: 'ResourcePolicy'
32753275
imports: 'selfLink'
32763276
description: 'A resource policy applied to this disk for automatic snapshot creations.'
3277+
- !ruby/object:Api::Type::Boolean
3278+
name: 'multiWriter'
3279+
description: |
3280+
Indicates whether or not the disk can be read/write attached to more than one instance.
3281+
min_version: beta
32773282
- !ruby/object:Api::Resource
32783283
name: 'Firewall'
32793284
kind: 'compute#firewall'

third_party/terraform/tests/resource_compute_disk_test.go.erb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,29 @@ func TestAccComputeDisk_interface(t *testing.T) {
480480
}
481481
<% end -%>
482482

483+
<% unless version == 'ga' -%>
484+
func TestAccComputeDisk_multiWriter(t *testing.T) {
485+
t.Parallel()
486+
instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
487+
diskName := fmt.Sprintf("tf-testd-%s", randString(t, 10))
488+
489+
vcrTest(t, resource.TestCase{
490+
PreCheck: func() { testAccPreCheck(t) },
491+
Providers: testAccProviders,
492+
Steps: []resource.TestStep{
493+
{
494+
Config: testAccComputeDisk_multiWriter(instanceName, diskName, true),
495+
},
496+
{
497+
ResourceName: "google_compute_disk.foobar",
498+
ImportState: true,
499+
ImportStateVerify: true,
500+
},
501+
},
502+
})
503+
}
504+
<% end -%>
505+
483506
func testAccCheckComputeDiskExists(t *testing.T, n, p string, disk *compute.Disk) resource.TestCheckFunc {
484507
return func(s *terraform.State) error {
485508
rs, ok := s.RootModule().Resources[n]
@@ -816,3 +839,48 @@ resource "google_compute_disk" "foobar" {
816839
`, diskName)
817840
}
818841
<% end -%>
842+
843+
<% unless version == 'ga' -%>
844+
func testAccComputeDisk_multiWriter(instance string, diskName string, enableMultiwriter bool) string {
845+
return fmt.Sprintf(`
846+
data "google_compute_image" "my_image" {
847+
family = "debian-9"
848+
project = "debian-cloud"
849+
}
850+
851+
resource "google_compute_disk" "foobar" {
852+
name = "%s"
853+
size = 10
854+
type = "pd-ssd"
855+
zone = "us-central1-a"
856+
multi_writer = %t
857+
}
858+
859+
resource "google_compute_instance" "foobar" {
860+
name = "%s"
861+
machine_type = "n2-standard-2"
862+
zone = "us-central1-a"
863+
can_ip_forward = false
864+
tags = ["foo", "bar"]
865+
866+
boot_disk {
867+
initialize_params {
868+
image = data.google_compute_image.my_image.self_link
869+
}
870+
}
871+
872+
attached_disk {
873+
source = google_compute_disk.foobar.name
874+
}
875+
876+
network_interface {
877+
network = "default"
878+
}
879+
880+
metadata = {
881+
foo = "bar"
882+
}
883+
}
884+
`, diskName, enableMultiwriter, instance)
885+
}
886+
<% end -%>

0 commit comments

Comments
 (0)