Skip to content

Commit 55b25d6

Browse files
Marked colab notebook execution tests that rely on dataform as min_version beta (#13003) (#21310)
[upstream:96f6489eecaabf8faa6a0d819a540dc4a1031df4] Signed-off-by: Modular Magician <[email protected]>
1 parent e600a48 commit 55b25d6

File tree

3 files changed

+13
-239
lines changed

3 files changed

+13
-239
lines changed

.changelog/13003.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google/services/colab/resource_colab_notebook_execution_generated_test.go

Lines changed: 0 additions & 239 deletions
Original file line numberDiff line numberDiff line change
@@ -140,245 +140,6 @@ resource "google_colab_notebook_execution" "notebook-execution" {
140140
`, context)
141141
}
142142

143-
func TestAccColabNotebookExecution_colabNotebookExecutionFullExample(t *testing.T) {
144-
t.Parallel()
145-
146-
context := map[string]interface{}{
147-
"project_id": envvar.GetTestProjectFromEnv(),
148-
"service_account": envvar.GetTestServiceAccountFromEnv(t),
149-
"random_suffix": acctest.RandString(t, 10),
150-
}
151-
152-
acctest.VcrTest(t, resource.TestCase{
153-
PreCheck: func() { acctest.AccTestPreCheck(t) },
154-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
155-
CheckDestroy: testAccCheckColabNotebookExecutionDestroyProducer(t),
156-
Steps: []resource.TestStep{
157-
{
158-
Config: testAccColabNotebookExecution_colabNotebookExecutionFullExample(context),
159-
},
160-
{
161-
ResourceName: "google_colab_notebook_execution.notebook-execution",
162-
ImportState: true,
163-
ImportStateVerify: true,
164-
ImportStateVerifyIgnore: []string{"direct_notebook_source", "location", "notebook_execution_job_id"},
165-
},
166-
},
167-
})
168-
}
169-
170-
func testAccColabNotebookExecution_colabNotebookExecutionFullExample(context map[string]interface{}) string {
171-
return acctest.Nprintf(`
172-
resource "google_colab_runtime_template" "my_runtime_template" {
173-
name = "tf-test-runtime-template-name%{random_suffix}"
174-
display_name = "Runtime template"
175-
location = "us-central1"
176-
177-
machine_spec {
178-
machine_type = "e2-standard-4"
179-
}
180-
181-
network_spec {
182-
enable_internet_access = true
183-
}
184-
}
185-
186-
resource "google_storage_bucket" "output_bucket" {
187-
name = "tf_test_my_bucket%{random_suffix}"
188-
location = "US"
189-
force_destroy = true
190-
uniform_bucket_level_access = true
191-
}
192-
193-
resource "google_storage_bucket_object" "notebook" {
194-
name = "hello_world.ipynb"
195-
bucket = google_storage_bucket.output_bucket.name
196-
content = <<EOF
197-
{
198-
"cells": [
199-
{
200-
"cell_type": "code",
201-
"execution_count": null,
202-
"metadata": {},
203-
"outputs": [],
204-
"source": [
205-
"print(\"Hello, World!\")"
206-
]
207-
}
208-
],
209-
"metadata": {
210-
"kernelspec": {
211-
"display_name": "Python 3",
212-
"language": "python",
213-
"name": "python3"
214-
},
215-
"language_info": {
216-
"codemirror_mode": {
217-
"name": "ipython",
218-
"version": 3
219-
},
220-
"file_extension": ".py",
221-
"mimetype": "text/x-python",
222-
"name": "python",
223-
"nbconvert_exporter": "python",
224-
"pygments_lexer": "ipython3",
225-
"version": "3.8.5"
226-
}
227-
},
228-
"nbformat": 4,
229-
"nbformat_minor": 4
230-
}
231-
EOF
232-
}
233-
234-
resource "google_colab_notebook_execution" "notebook-execution" {
235-
notebook_execution_job_id = "tf-test-colab-notebook-execution%{random_suffix}"
236-
display_name = "Notebook execution full"
237-
location = "us-central1"
238-
239-
execution_timeout = "86400s"
240-
gcs_notebook_source {
241-
uri = "gs://${google_storage_bucket_object.notebook.bucket}/${google_storage_bucket_object.notebook.name}"
242-
generation = google_storage_bucket_object.notebook.generation
243-
}
244-
245-
service_account = "%{service_account}"
246-
247-
gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
248-
notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"
249-
250-
depends_on = [
251-
google_storage_bucket_object.notebook,
252-
google_storage_bucket.output_bucket,
253-
google_colab_runtime_template.my_runtime_template,
254-
]
255-
256-
}
257-
`, context)
258-
}
259-
260-
func TestAccColabNotebookExecution_colabNotebookExecutionDataformExample(t *testing.T) {
261-
t.Parallel()
262-
acctest.BootstrapIamMembers(t, []acctest.IamMember{
263-
{
264-
Member: "serviceAccount:service-{project_number}@gcp-sa-dataform.iam.gserviceaccount.com",
265-
Role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
266-
},
267-
})
268-
269-
context := map[string]interface{}{
270-
"project_id": envvar.GetTestProjectFromEnv(),
271-
"service_account": envvar.GetTestServiceAccountFromEnv(t),
272-
"key_name": acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name,
273-
"random_suffix": acctest.RandString(t, 10),
274-
}
275-
276-
acctest.VcrTest(t, resource.TestCase{
277-
PreCheck: func() { acctest.AccTestPreCheck(t) },
278-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
279-
CheckDestroy: testAccCheckColabNotebookExecutionDestroyProducer(t),
280-
Steps: []resource.TestStep{
281-
{
282-
Config: testAccColabNotebookExecution_colabNotebookExecutionDataformExample(context),
283-
},
284-
{
285-
ResourceName: "google_colab_notebook_execution.notebook-execution",
286-
ImportState: true,
287-
ImportStateVerify: true,
288-
ImportStateVerifyIgnore: []string{"direct_notebook_source", "location", "notebook_execution_job_id"},
289-
},
290-
},
291-
})
292-
}
293-
294-
func testAccColabNotebookExecution_colabNotebookExecutionDataformExample(context map[string]interface{}) string {
295-
return acctest.Nprintf(`
296-
resource "google_colab_runtime_template" "my_runtime_template" {
297-
name = "tf-test-runtime-template-name%{random_suffix}"
298-
display_name = "Runtime template"
299-
location = "us-central1"
300-
301-
machine_spec {
302-
machine_type = "e2-standard-4"
303-
}
304-
305-
network_spec {
306-
enable_internet_access = true
307-
}
308-
}
309-
310-
resource "google_storage_bucket" "output_bucket" {
311-
name = "tf_test_my_bucket%{random_suffix}"
312-
location = "US"
313-
force_destroy = true
314-
uniform_bucket_level_access = true
315-
}
316-
317-
resource "google_secret_manager_secret" "secret" {
318-
secret_id = "secret%{random_suffix}"
319-
320-
replication {
321-
auto {}
322-
}
323-
}
324-
325-
resource "google_secret_manager_secret_version" "secret_version" {
326-
secret = google_secret_manager_secret.secret.id
327-
328-
secret_data = "secret-data"
329-
}
330-
331-
resource "google_dataform_repository" "dataform_repository" {
332-
name = "tf-test-dataform-repository%{random_suffix}"
333-
display_name = "dataform_repository"
334-
npmrc_environment_variables_secret_version = google_secret_manager_secret_version.secret_version.id
335-
kms_key_name = "%{key_name}"
336-
337-
labels = {
338-
label_foo1 = "label-bar1"
339-
}
340-
341-
git_remote_settings {
342-
url = "https://github.com/OWNER/REPOSITORY.git"
343-
default_branch = "main"
344-
authentication_token_secret_version = google_secret_manager_secret_version.secret_version.id
345-
}
346-
347-
workspace_compilation_overrides {
348-
default_database = "database"
349-
schema_suffix = "_suffix"
350-
table_prefix = "prefix_"
351-
}
352-
353-
}
354-
355-
resource "google_colab_notebook_execution" "notebook-execution" {
356-
display_name = "Notebook execution Dataform"
357-
location = "us-central1"
358-
359-
dataform_repository_source {
360-
commit_sha = "randomsha123"
361-
dataform_repository_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/repositories/${google_dataform_repository.dataform_repository.name}"
362-
}
363-
364-
notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"
365-
366-
gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
367-
368-
service_account = "%{service_account}"
369-
370-
depends_on = [
371-
google_colab_runtime_template.my_runtime_template,
372-
google_storage_bucket.output_bucket,
373-
google_secret_manager_secret_version.secret_version,
374-
google_dataform_repository.dataform_repository,
375-
google_secret_manager_secret.secret,
376-
]
377-
378-
}
379-
`, context)
380-
}
381-
382143
func testAccCheckColabNotebookExecutionDestroyProducer(t *testing.T) func(s *terraform.State) error {
383144
return func(s *terraform.State) error {
384145
for name, rs := range s.RootModule().Resources {

website/docs/r/colab_notebook_execution.html.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ resource "google_colab_notebook_execution" "notebook-execution" {
115115

116116
```hcl
117117
resource "google_colab_runtime_template" "my_runtime_template" {
118+
provider = google-beta
118119
name = "runtime-template-name"
119120
display_name = "Runtime template"
120121
location = "us-central1"
@@ -129,13 +130,15 @@ resource "google_colab_runtime_template" "my_runtime_template" {
129130
}
130131
131132
resource "google_storage_bucket" "output_bucket" {
133+
provider = google-beta
132134
name = "my_bucket"
133135
location = "US"
134136
force_destroy = true
135137
uniform_bucket_level_access = true
136138
}
137139
138140
resource "google_storage_bucket_object" "notebook" {
141+
provider = google-beta
139142
name = "hello_world.ipynb"
140143
bucket = google_storage_bucket.output_bucket.name
141144
content = <<EOF
@@ -177,6 +180,7 @@ resource "google_storage_bucket_object" "notebook" {
177180
}
178181
179182
resource "google_colab_notebook_execution" "notebook-execution" {
183+
provider = google-beta
180184
notebook_execution_job_id = "colab-notebook-execution"
181185
display_name = "Notebook execution full"
182186
location = "us-central1"
@@ -205,6 +209,7 @@ resource "google_colab_notebook_execution" "notebook-execution" {
205209

206210
```hcl
207211
resource "google_colab_runtime_template" "my_runtime_template" {
212+
provider = google-beta
208213
name = "runtime-template-name"
209214
display_name = "Runtime template"
210215
location = "us-central1"
@@ -219,13 +224,15 @@ resource "google_colab_runtime_template" "my_runtime_template" {
219224
}
220225
221226
resource "google_storage_bucket" "output_bucket" {
227+
provider = google-beta
222228
name = "my_bucket"
223229
location = "US"
224230
force_destroy = true
225231
uniform_bucket_level_access = true
226232
}
227233
228234
resource "google_secret_manager_secret" "secret" {
235+
provider = google-beta
229236
secret_id = "secret"
230237
231238
replication {
@@ -234,12 +241,14 @@ resource "google_secret_manager_secret" "secret" {
234241
}
235242
236243
resource "google_secret_manager_secret_version" "secret_version" {
244+
provider = google-beta
237245
secret = google_secret_manager_secret.secret.id
238246
239247
secret_data = "secret-data"
240248
}
241249
242250
resource "google_dataform_repository" "dataform_repository" {
251+
provider = google-beta
243252
name = "dataform-repository"
244253
display_name = "dataform_repository"
245254
npmrc_environment_variables_secret_version = google_secret_manager_secret_version.secret_version.id
@@ -264,6 +273,7 @@ resource "google_dataform_repository" "dataform_repository" {
264273
}
265274
266275
resource "google_colab_notebook_execution" "notebook-execution" {
276+
provider = google-beta
267277
display_name = "Notebook execution Dataform"
268278
location = "us-central1"
269279

0 commit comments

Comments
 (0)