File tree 2 files changed +37
-0
lines changed 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,34 @@ def create_instance(instance_id):
62
62
# [END spanner_create_instance]
63
63
64
64
65
+ # [START spanner_create_instance_with_processing_units]
66
+ def create_instance_with_processing_units (instance_id , processing_units ):
67
+ """Creates an instance."""
68
+ spanner_client = spanner .Client ()
69
+
70
+ config_name = "{}/instanceConfigs/regional-us-central1" .format (
71
+ spanner_client .project_name
72
+ )
73
+
74
+ instance = spanner_client .instance (
75
+ instance_id ,
76
+ configuration_name = config_name ,
77
+ display_name = "This is a display name." ,
78
+ processing_units = processing_units ,
79
+ )
80
+
81
+ operation = instance .create ()
82
+
83
+ print ("Waiting for operation to complete..." )
84
+ operation .result (120 )
85
+
86
+ print ("Created instance {} with {} processing units" .format (
87
+ instance_id , instance .processing_units ))
88
+
89
+
90
+ # [END spanner_create_instance_with_processing_units]
91
+
92
+
65
93
# [START spanner_create_database]
66
94
def create_database (instance_id , database_id ):
67
95
"""Creates a database and tables for sample data."""
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ def cleanup_old_instances(spanner_client):
53
53
54
54
55
55
INSTANCE_ID = unique_instance_id ()
56
+ LCI_INSTANCE_ID = unique_instance_id ()
56
57
DATABASE_ID = unique_database_id ()
57
58
CMEK_DATABASE_ID = unique_database_id ()
58
59
@@ -81,6 +82,14 @@ def test_create_instance(spanner_instance):
81
82
spanner_instance .reload ()
82
83
83
84
85
+ def test_create_instance_with_processing_units (capsys ):
86
+ processing_units = 500
87
+ snippets .create_instance_with_processing_units (LCI_INSTANCE_ID , processing_units )
88
+ out , _ = capsys .readouterr ()
89
+ assert LCI_INSTANCE_ID in out
90
+ assert "{} processing units" .format (processing_units ) in out
91
+
92
+
84
93
def test_create_database (database ):
85
94
# Reload will only succeed if the database exists.
86
95
database .reload ()
You can’t perform that action at this time.
0 commit comments