Skip to content

Commit 8219c10

Browse files
authored
chore: add sample name label to created instances (#420)
* chore: add sample name label to created instances Make leaked instances more obviously debuggable * tests: improve sample name (include snippet) Also, ensure we delete the LCI instance.
1 parent 2318264 commit 8219c10

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

packages/google-cloud-spanner/samples/samples/autocommit_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def spanner_instance():
4242
instance_config,
4343
labels={
4444
"cloud_spanner_samples": "true",
45+
"sample_name": "autocommit",
4546
"created": str(int(time.time()))
4647
}
4748
)

packages/google-cloud-spanner/samples/samples/backup_sample_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def spanner_instance():
5959
INSTANCE_ID,
6060
instance_config,
6161
labels={
62-
"cloud_spanner_samples": "true",
63-
"created": str(int(time.time()))
62+
"cloud_spanner_samples": "true",
63+
"sample_name": "backup",
64+
"created": str(int(time.time()))
6465
}
6566
)
6667
op = instance.create()

packages/google-cloud-spanner/samples/samples/quickstart_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ def create_instance():
4040
instance = spanner_client.instance(
4141
INSTANCE_ID,
4242
instance_config,
43-
labels={"cloud_spanner_samples": "true", "created": str(int(time.time()))},
43+
labels={
44+
"cloud_spanner_samples": "true",
45+
"sample_name": "quickstart",
46+
"created": str(int(time.time()))
47+
},
4448
)
4549
op = instance.create()
4650
op.result(120) # block until completion

packages/google-cloud-spanner/samples/samples/snippets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def create_instance(instance_id):
4747
node_count=1,
4848
labels={
4949
"cloud_spanner_samples": "true",
50+
"sample_name": "snippets-create_instance",
5051
"created": str(int(time.time()))
5152
}
5253
)
@@ -76,6 +77,11 @@ def create_instance_with_processing_units(instance_id, processing_units):
7677
configuration_name=config_name,
7778
display_name="This is a display name.",
7879
processing_units=processing_units,
80+
labels={
81+
"cloud_spanner_samples": "true",
82+
"sample_name": "snippets-create_instance_with_processing_units",
83+
"created": str(int(time.time()))
84+
}
7985
)
8086

8187
operation = instance.create()

packages/google-cloud-spanner/samples/samples/snippets_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def test_create_instance_with_processing_units(capsys):
8888
out, _ = capsys.readouterr()
8989
assert LCI_INSTANCE_ID in out
9090
assert "{} processing units".format(processing_units) in out
91+
spanner_client = spanner.Client()
92+
instance = spanner_client.instance(LCI_INSTANCE_ID)
93+
instance.delete()
9194

9295

9396
def test_create_database(database):

0 commit comments

Comments
 (0)