Skip to content

Commit bbe8f45

Browse files
chore(tests): re-enable pipeline system tests on kokoro (#1153)
Kokoro tests for pipelines were previously disabled until the backend supports the feature. This branch will re-enable those tests, when the backend is ready Aslo removing index_mode, since this feature was pushed back to a future release
1 parent 4ee909a commit bbe8f45

File tree

8 files changed

+6
-84
lines changed

8 files changed

+6
-84
lines changed

google/cloud/firestore_v1/async_pipeline.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ async def execute(
6868
transaction: "AsyncTransaction" | None = None,
6969
read_time: datetime.datetime | None = None,
7070
explain_options: PipelineExplainOptions | None = None,
71-
index_mode: str | None = None,
7271
additional_options: dict[str, Value | Constant] = {},
7372
) -> PipelineSnapshot[PipelineResult]:
7473
"""
@@ -87,10 +86,8 @@ async def execute(
8786
explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
8887
Options to enable query profiling for this query. When set,
8988
explain_metrics will be available on the returned list.
90-
index_mode (Optional[str]): Configures the pipeline to require a certain type of indexes to be present.
91-
Firestore will reject the request if there is not appropiate indexes to serve the query.
9289
additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
93-
These options will take precedence over method argument if there is a conflict (e.g. explain_options, index_mode)
90+
These options will take precedence over method argument if there is a conflict (e.g. explain_options)
9491
"""
9592
kwargs = {k: v for k, v in locals().items() if k != "self"}
9693
stream = AsyncPipelineStream(PipelineResult, self, **kwargs)
@@ -103,7 +100,6 @@ def stream(
103100
read_time: datetime.datetime | None = None,
104101
transaction: "AsyncTransaction" | None = None,
105102
explain_options: PipelineExplainOptions | None = None,
106-
index_mode: str | None = None,
107103
additional_options: dict[str, Value | Constant] = {},
108104
) -> AsyncPipelineStream[PipelineResult]:
109105
"""
@@ -122,10 +118,8 @@ def stream(
122118
explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
123119
Options to enable query profiling for this query. When set,
124120
explain_metrics will be available on the returned generator.
125-
index_mode (Optional[str]): Configures the pipeline to require a certain type of indexes to be present.
126-
Firestore will reject the request if there is not appropiate indexes to serve the query.
127121
additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
128-
These options will take precedence over method argument if there is a conflict (e.g. explain_options, index_mode)
122+
These options will take precedence over method argument if there is a conflict (e.g. explain_options)
129123
"""
130124
kwargs = {k: v for k, v in locals().items() if k != "self"}
131125
return AsyncPipelineStream(PipelineResult, self, **kwargs)

google/cloud/firestore_v1/pipeline.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def execute(
6565
transaction: "Transaction" | None = None,
6666
read_time: datetime.datetime | None = None,
6767
explain_options: PipelineExplainOptions | None = None,
68-
index_mode: str | None = None,
6968
additional_options: dict[str, Value | Constant] = {},
7069
) -> PipelineSnapshot[PipelineResult]:
7170
"""
@@ -84,10 +83,8 @@ def execute(
8483
explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
8584
Options to enable query profiling for this query. When set,
8685
explain_metrics will be available on the returned list.
87-
index_mode (Optional[str]): Configures the pipeline to require a certain type of indexes to be present.
88-
Firestore will reject the request if there is not appropiate indexes to serve the query.
8986
additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
90-
These options will take precedence over method argument if there is a conflict (e.g. explain_options, index_mode)
87+
These options will take precedence over method argument if there is a conflict (e.g. explain_options)
9188
"""
9289
kwargs = {k: v for k, v in locals().items() if k != "self"}
9390
stream = PipelineStream(PipelineResult, self, **kwargs)
@@ -100,7 +97,6 @@ def stream(
10097
transaction: "Transaction" | None = None,
10198
read_time: datetime.datetime | None = None,
10299
explain_options: PipelineExplainOptions | None = None,
103-
index_mode: str | None = None,
104100
additional_options: dict[str, Value | Constant] = {},
105101
) -> PipelineStream[PipelineResult]:
106102
"""
@@ -119,10 +115,8 @@ def stream(
119115
explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
120116
Options to enable query profiling for this query. When set,
121117
explain_metrics will be available on the returned generator.
122-
index_mode (Optional[str]): Configures the pipeline to require a certain type of indexes to be present.
123-
Firestore will reject the request if there is not appropiate indexes to serve the query.
124118
additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
125-
These options will take precedence over method argument if there is a conflict (e.g. explain_options, index_mode)
119+
These options will take precedence over method argument if there is a conflict (e.g. explain_options)
126120
"""
127121
kwargs = {k: v for k, v in locals().items() if k != "self"}
128122
return PipelineStream(PipelineResult, self, **kwargs)

google/cloud/firestore_v1/pipeline_result.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def __init__(
178178
transaction: Transaction | AsyncTransaction | None,
179179
read_time: datetime.datetime | None,
180180
explain_options: PipelineExplainOptions | None,
181-
index_mode: str | None,
182181
additional_options: dict[str, Constant | Value],
183182
):
184183
# public
@@ -192,7 +191,6 @@ def __init__(
192191
self._explain_stats: ExplainStats | None = None
193192
self._explain_options: PipelineExplainOptions | None = explain_options
194193
self._return_type = return_type
195-
self._index_mode = index_mode
196194
self._additonal_options = {
197195
k: v if isinstance(v, Value) else v._to_pb()
198196
for k, v in additional_options.items()
@@ -226,8 +224,6 @@ def _build_request(self) -> ExecutePipelineRequest:
226224
options = {}
227225
if self._explain_options:
228226
options["explain_options"] = self._explain_options._to_value()
229-
if self._index_mode:
230-
options["index_mode"] = Value(string_value=self._index_mode)
231227
if self._additonal_options:
232228
options.update(self._additonal_options)
233229
request = ExecutePipelineRequest(

tests/system/test__helpers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
EMULATOR_CREDS = EmulatorCreds()
1616
FIRESTORE_EMULATOR = os.environ.get(_FIRESTORE_EMULATOR_HOST) is not None
1717
FIRESTORE_OTHER_DB = os.environ.get("SYSTEM_TESTS_DATABASE", "system-tests-named-db")
18-
FIRESTORE_ENTERPRISE_DB = os.environ.get("ENTERPRISE_DATABASE", "enterprise-db")
18+
FIRESTORE_ENTERPRISE_DB = os.environ.get("ENTERPRISE_DATABASE", "enterprise-db-native")
1919

2020
# run all tests against default database, and a named database
2121
TEST_DATABASES = [None, FIRESTORE_OTHER_DB]
2222
TEST_DATABASES_W_ENTERPRISE = TEST_DATABASES + [FIRESTORE_ENTERPRISE_DB]
23-
# TODO remove when kokoro fully supports enterprise mode/pipelines
24-
IS_KOKORO_TEST = os.getenv("KOKORO_JOB_NAME") is not None

tests/system/test_pipeline_acceptance.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,10 @@
3333

3434
from google.cloud.firestore import Client, AsyncClient
3535

36-
from test__helpers import FIRESTORE_ENTERPRISE_DB, IS_KOKORO_TEST
36+
from test__helpers import FIRESTORE_ENTERPRISE_DB
3737

3838
FIRESTORE_PROJECT = os.environ.get("GCLOUD_PROJECT")
3939

40-
# TODO: enable kokoro tests when internal test project is whitelisted
41-
pytestmark = pytest.mark.skipif(
42-
condition=IS_KOKORO_TEST,
43-
reason="Pipeline tests are currently not supported by kokoro",
44-
)
45-
4640
test_dir_name = os.path.dirname(__file__)
4741

4842
id_format = (

tests/system/test_system.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
ENTERPRISE_MODE_ERROR,
4747
TEST_DATABASES,
4848
TEST_DATABASES_W_ENTERPRISE,
49-
IS_KOKORO_TEST,
5049
FIRESTORE_ENTERPRISE_DB,
5150
)
5251

@@ -67,12 +66,6 @@ def _get_credentials_and_project():
6766

6867
@pytest.fixture(scope="session")
6968
def database(request):
70-
from test__helpers import FIRESTORE_ENTERPRISE_DB
71-
72-
# enterprise mode currently does not support RunQuery calls in prod on kokoro test project
73-
# TODO: remove skip when kokoro test project supports full enterprise mode
74-
if request.param == FIRESTORE_ENTERPRISE_DB and IS_KOKORO_TEST:
75-
pytest.skip("enterprise mode does not support RunQuery on kokoro")
7669
return request.param
7770

7871

@@ -101,11 +94,6 @@ def verify_pipeline(query):
10194
"""
10295
from google.cloud.firestore_v1.base_aggregation import BaseAggregationQuery
10396

104-
# return early on kokoro. Test project doesn't currently support pipelines
105-
# TODO: enable pipeline verification when kokoro test project is whitelisted
106-
if IS_KOKORO_TEST:
107-
pytest.skip("skipping pipeline verification on kokoro")
108-
10997
def _clean_results(results):
11098
if isinstance(results, dict):
11199
return {k: _clean_results(v) for k, v in results.items()}
@@ -1771,22 +1759,6 @@ def test_pipeline_explain_options_using_additional_options(
17711759
assert "Execution:" in text_stats
17721760

17731761

1774-
@pytest.mark.skipif(
1775-
FIRESTORE_EMULATOR, reason="Query profile not supported in emulator."
1776-
)
1777-
@pytest.mark.parametrize("database", [FIRESTORE_ENTERPRISE_DB], indirect=True)
1778-
def test_pipeline_index_mode(database, query_docs):
1779-
"""test pipeline query with explicit index mode"""
1780-
1781-
collection, _, allowed_vals = query_docs
1782-
client = collection._client
1783-
query = collection.where(filter=FieldFilter("a", "==", 1))
1784-
pipeline = client.pipeline().create_from(query)
1785-
with pytest.raises(InvalidArgument) as e:
1786-
pipeline.execute(index_mode="fake_index")
1787-
assert "Invalid index_mode: fake_index" in str(e)
1788-
1789-
17901762
@pytest.mark.parametrize("database", TEST_DATABASES, indirect=True)
17911763
def test_query_stream_w_read_time(query_docs, cleanup, database):
17921764
collection, stored, allowed_vals = query_docs
@@ -1825,7 +1797,6 @@ def test_query_stream_w_read_time(query_docs, cleanup, database):
18251797
assert new_values[new_ref.id] == new_data
18261798

18271799

1828-
@pytest.mark.skipif(IS_KOKORO_TEST, reason="skipping pipeline verification on kokoro")
18291800
@pytest.mark.parametrize("database", [FIRESTORE_ENTERPRISE_DB], indirect=True)
18301801
def test_pipeline_w_read_time(query_docs, cleanup, database):
18311802
collection, stored, allowed_vals = query_docs

tests/system/test_system_async.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
ENTERPRISE_MODE_ERROR,
5858
TEST_DATABASES,
5959
TEST_DATABASES_W_ENTERPRISE,
60-
IS_KOKORO_TEST,
6160
FIRESTORE_ENTERPRISE_DB,
6261
)
6362

@@ -145,12 +144,6 @@ def _verify_explain_metrics_analyze_false(explain_metrics):
145144

146145
@pytest.fixture(scope="session")
147146
def database(request):
148-
from test__helpers import FIRESTORE_ENTERPRISE_DB
149-
150-
# enterprise mode currently does not support RunQuery calls in prod on kokoro test project
151-
# TODO: remove skip when kokoro test project supports full enterprise mode
152-
if request.param == FIRESTORE_ENTERPRISE_DB and IS_KOKORO_TEST:
153-
pytest.skip("enterprise mode does not support RunQuery on kokoro")
154147
return request.param
155148

156149

@@ -181,11 +174,6 @@ async def verify_pipeline(query):
181174
"""
182175
from google.cloud.firestore_v1.base_aggregation import BaseAggregationQuery
183176

184-
# return early on kokoro. Test project doesn't currently support pipelines
185-
# TODO: enable pipeline verification when kokoro test project is whitelisted
186-
if IS_KOKORO_TEST:
187-
pytest.skip("skipping pipeline verification on kokoro")
188-
189177
def _clean_results(results):
190178
if isinstance(results, dict):
191179
return {k: _clean_results(v) for k, v in results.items()}
@@ -1694,7 +1682,6 @@ async def test_pipeline_explain_options_using_additional_options(
16941682
assert "Execution:" in text_stats
16951683

16961684

1697-
@pytest.mark.skipif(IS_KOKORO_TEST, reason="skipping pipeline verification on kokoro")
16981685
@pytest.mark.parametrize("database", [FIRESTORE_ENTERPRISE_DB], indirect=True)
16991686
async def test_pipeline_w_read_time(query_docs, cleanup, database):
17001687
collection, stored, allowed_vals = query_docs

tests/unit/v1/test_pipeline_result.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,20 @@ def test_ctor(self):
213213
expected_transaction = object()
214214
expected_read_time = 123
215215
expected_explain_options = object()
216-
expected_index_mode = "mode"
217216
expected_addtl_options = {}
218217
source = PipelineStream(
219218
expected_type,
220219
expected_pipeline,
221220
expected_transaction,
222221
expected_read_time,
223222
expected_explain_options,
224-
expected_index_mode,
225223
expected_addtl_options,
226224
)
227225
instance = self._make_one(in_arr, source)
228226
assert instance._return_type == expected_type
229227
assert instance.pipeline == expected_pipeline
230228
assert instance._client == expected_pipeline._client
231229
assert instance._additonal_options == expected_addtl_options
232-
assert instance._index_mode == expected_index_mode
233230
assert instance._explain_options == expected_explain_options
234231
assert instance._explain_stats is None
235232
assert instance._started is True
@@ -281,7 +278,6 @@ def _mock_init_args(self):
281278
"transaction": None,
282279
"read_time": None,
283280
"explain_options": None,
284-
"index_mode": None,
285281
"additional_options": {},
286282
}
287283

@@ -312,7 +308,6 @@ def test_explain_stats(self):
312308
@pytest.mark.parametrize(
313309
"init_kwargs,expected_options",
314310
[
315-
({"index_mode": "mode"}, {"index_mode": encode_value("mode")}),
316311
(
317312
{"explain_options": PipelineExplainOptions()},
318313
{"explain_options": encode_value({"mode": "analyze"})},
@@ -336,13 +331,6 @@ def test_explain_stats(self):
336331
},
337332
{"explain_options": encode_value("override")},
338333
),
339-
(
340-
{
341-
"index_mode": "mode",
342-
"additional_options": {"index_mode": Constant("new")},
343-
},
344-
{"index_mode": encode_value("new")},
345-
),
346334
],
347335
)
348336
def test_build_request_options(self, init_kwargs, expected_options):

0 commit comments

Comments
 (0)