-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make notebooks wait for active state and enable stopping/starting ins…
…… (#9971) (#6965) * Make notebooks wait for active state and enable stopping/starting instances using the desired_state field * ignore update_time [upstream:18072d2b0665b0182e8bcd677fc1d0ca75693507] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
887b319
commit b652fb0
Showing
5 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
made `google_notebooks_instance` wait for active state on creation and enable stopping/starting instances. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
google-beta/services/notebooks/resource_notebooks_instance_state_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
package notebooks_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" | ||
) | ||
|
||
func TestAccNotebooksInstance_state(t *testing.T) { | ||
t.Parallel() | ||
|
||
prefix := fmt.Sprintf("%d", acctest.RandInt(t)) | ||
name := fmt.Sprintf("tf-%s", prefix) | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccNotebooksInstance_basic_active(name), | ||
}, | ||
{ | ||
ResourceName: "google_notebooks_instance.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ExpectNonEmptyPlan: true, | ||
ImportStateVerifyIgnore: []string{"container_image", "metadata", "vm_image", "desired_state", "update_time"}, | ||
}, | ||
{ | ||
Config: testAccNotebooksInstance_basic_stopped(name), | ||
}, | ||
{ | ||
ResourceName: "google_notebooks_instance.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ExpectNonEmptyPlan: true, | ||
ImportStateVerifyIgnore: []string{"container_image", "metadata", "vm_image", "desired_state", "update_time"}, | ||
}, | ||
{ | ||
Config: testAccNotebooksInstance_basic_active(name), | ||
}, | ||
{ | ||
ResourceName: "google_notebooks_instance.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ExpectNonEmptyPlan: true, | ||
ImportStateVerifyIgnore: []string{"container_image", "metadata", "vm_image", "desired_state", "update_time"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccNotebooksInstance_basic_active(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_notebooks_instance" "test" { | ||
name = "%s" | ||
location = "us-west1-a" | ||
machine_type = "e2-medium" | ||
vm_image { | ||
project = "deeplearning-platform-release" | ||
image_family = "tf-latest-cpu" | ||
} | ||
desired_state = "ACTIVE" | ||
} | ||
`, name) | ||
} | ||
|
||
func testAccNotebooksInstance_basic_stopped(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_notebooks_instance" "test" { | ||
name = "%s" | ||
location = "us-west1-a" | ||
machine_type = "e2-medium" | ||
vm_image { | ||
project = "deeplearning-platform-release" | ||
image_family = "tf-latest-cpu" | ||
} | ||
desired_state = "STOPPED" | ||
} | ||
`, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters