Skip to content

Commit e163981

Browse files
committed
Stop uisng a designated tests project ID.
This is because the project ID can be determined directly from the file pointed to by GOOGLE_APPLICATION_CREDENTIALS. Fixes #2263.
1 parent 6b42be9 commit e163981

File tree

14 files changed

+12
-50
lines changed

14 files changed

+12
-50
lines changed

CONTRIBUTING.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ Running System Tests
153153
so you'll need to provide some environment variables to facilitate
154154
authentication to your project:
155155

156-
- ``GOOGLE_CLOUD_TESTS_PROJECT_ID``: Developers Console project ID (e.g.
157-
bamboo-shift-455).
158156
- ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file;
159157
see ``system_tests/app_credentials.json.sample`` as an example. Such a file
160158
can be downloaded directly from the developer's console by clicking
@@ -182,12 +180,12 @@ Running System Tests
182180
$ export CLOUDSDK_PYTHON_SITEPACKAGES=1
183181

184182
# Authenticate the gcloud tool with your account.
185-
$ JSON_CREDENTIALS_FILE="path/to/app_credentials.json"
186-
$ gcloud auth activate-service-account --key-file=$JSON_CREDENTIALS_FILE
183+
$ GOOGLE_APPLICATION_CREDENTIALS="path/to/app_credentials.json"
184+
$ gcloud auth activate-service-account \
185+
> --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
187186

188187
# Create the indexes
189-
$ gcloud preview datastore create-indexes system_tests/data/index.yaml \
190-
> --project=$GOOGLE_CLOUD_TESTS_PROJECT_ID
188+
$ gcloud preview datastore create-indexes system_tests/data/index.yaml
191189

192190
# Restore your environment to its previous state.
193191
$ unset CLOUDSDK_PYTHON_SITEPACKAGES

google/cloud/environment_vars.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
PROJECT = 'GOOGLE_CLOUD_PROJECT'
2222
"""Environment variable defining default project."""
2323

24-
TESTS_PROJECT = 'GOOGLE_CLOUD_TESTS_PROJECT_ID'
25-
"""Environment variable defining project for tests."""
26-
2724
GCD_DATASET = 'DATASTORE_DATASET'
2825
"""Environment variable defining default dataset ID under GCD."""
2926

system_tests/bigquery.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import unittest
1818

1919
from google.cloud import _helpers
20-
from google.cloud.environment_vars import TESTS_PROJECT
2120
from google.cloud import bigquery
2221
from google.cloud.exceptions import Forbidden
2322

@@ -52,7 +51,6 @@ class Config(object):
5251

5352

5453
def setUpModule():
55-
_helpers.PROJECT = TESTS_PROJECT
5654
Config.CLIENT = bigquery.Client()
5755

5856

system_tests/bigtable.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from google.cloud.bigtable.row_filters import RowFilterUnion
3030
from google.cloud.bigtable.row_data import Cell
3131
from google.cloud.bigtable.row_data import PartialRowData
32-
from google.cloud.environment_vars import TESTS_PROJECT
3332

3433
from retry import RetryErrors
3534
from retry import RetryResult
@@ -92,7 +91,6 @@ def _retry_on_unavailable(exc):
9291

9392
def setUpModule():
9493
from grpc._channel import _Rendezvous
95-
_helpers.PROJECT = TESTS_PROJECT
9694
Config.CLIENT = Client(admin=True)
9795
Config.INSTANCE = Config.CLIENT.instance(INSTANCE_ID, LOCATION_ID)
9896
retry = RetryErrors(_Rendezvous, error_predicate=_retry_on_unavailable)

system_tests/clear_datastore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import six
2222

2323
from google.cloud import datastore
24-
from google.cloud.environment_vars import TESTS_PROJECT
2524

2625

2726
FETCH_MAX = 20
@@ -90,7 +89,7 @@ def remove_kind(kind, client):
9089
def remove_all_entities(client=None):
9190
if client is None:
9291
# Get a client that uses the test dataset.
93-
client = datastore.Client(project=os.getenv(TESTS_PROJECT))
92+
client = datastore.Client()
9493
for kind in ALL_KINDS:
9594
remove_kind(kind, client)
9695

system_tests/datastore.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from google.cloud import datastore
2424
from google.cloud.datastore.helpers import GeoPoint
2525
from google.cloud.environment_vars import GCD_DATASET
26-
from google.cloud.environment_vars import TESTS_PROJECT
2726
from google.cloud.exceptions import Conflict
2827

2928
import clear_datastore
@@ -55,7 +54,6 @@ def setUpModule():
5554
# Isolated namespace so concurrent test runs don't collide.
5655
test_namespace = 'ns' + unique_resource_id()
5756
if emulator_dataset is None:
58-
_helpers.PROJECT = TESTS_PROJECT
5957
Config.CLIENT = datastore.Client(namespace=test_namespace)
6058
else:
6159
credentials = EmulatorCreds()

system_tests/language.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import unittest
1616

1717
from google.cloud import _helpers
18-
from google.cloud.environment_vars import TESTS_PROJECT
1918
from google.cloud import exceptions
2019
from google.cloud import language
2120
from google.cloud import storage
@@ -39,7 +38,6 @@ class Config(object):
3938

4039

4140
def setUpModule():
42-
_helpers.PROJECT = TESTS_PROJECT
4341
Config.CLIENT = language.Client()
4442
# Now create a bucket for GCS stored content.
4543
storage_client = storage.Client()
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export GOOGLE_APPLICATION_CREDENTIALS="app_credentials.json.sample"
2-
export GOOGLE_CLOUD_TESTS_PROJECT_ID="my-project"
32
export GOOGLE_CLOUD_REMOTE_FOR_LINT="upstream"
43
export GOOGLE_CLOUD_BRANCH_FOR_LINT="master"

system_tests/logging_.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from google.cloud.logging.handlers.transports import SyncTransport
2222
from google.cloud.logging import client
2323
from google.cloud import _helpers
24-
from google.cloud.environment_vars import TESTS_PROJECT
2524

2625
from retry import RetryErrors
2726
from retry import RetryResult
@@ -52,7 +51,6 @@ class Config(object):
5251

5352

5453
def setUpModule():
55-
_helpers.PROJECT = TESTS_PROJECT
5654
Config.CLIENT = client.Client()
5755

5856

system_tests/monitoring.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import unittest
1616

1717
from google.cloud import _helpers
18-
from google.cloud.environment_vars import TESTS_PROJECT
1918
from google.cloud.exceptions import InternalServerError
2019
from google.cloud.exceptions import NotFound
2120
from google.cloud.exceptions import ServiceUnavailable
@@ -30,10 +29,6 @@
3029
retry_503 = RetryErrors(ServiceUnavailable)
3130

3231

33-
def setUpModule():
34-
_helpers.PROJECT = TESTS_PROJECT
35-
36-
3732
class TestMonitoring(unittest.TestCase):
3833

3934
def test_fetch_metric_descriptor(self):

0 commit comments

Comments
 (0)