Skip to content

Commit 5319285

Browse files
committed
PYCBC-1704: Allow eventing function mgmt test fixtures to ignore
EventingFunctionNotFoundException Changes ======= * Fixtures that drop an eventing function catch and ignore `EventingFunctionNotFoundException` Results ======= Eventing function mgmt tests do not failing intermittently when a fixture is attempting to drop a function (e.g. cleanup) Change-Id: I45cc1ba5ba468159a8343c92f406dbd2e6a2b6dc Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/233472 Reviewed-by: Michael Reiche <michael.reiche@couchbase.com> Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
1 parent 9706219 commit 5319285

2 files changed

Lines changed: 46 additions & 22 deletions

File tree

acouchbase/tests/eventingmgmt_t.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,19 @@ async def create_eventing_function(self, cb_env):
127127
@pytest_asyncio.fixture()
128128
async def drop_eventing_function(self, cb_env):
129129
yield
130-
await cb_env.efm.drop_function(self.TEST_EVT_NAME)
130+
try:
131+
await cb_env.efm.drop_function(self.TEST_EVT_NAME)
132+
except EventingFunctionNotFoundException:
133+
pass
131134

132135
@pytest_asyncio.fixture()
133136
async def drop_eventing_functions(self, cb_env):
134137
yield
135138
for fn_name in self.function_names:
136-
await cb_env.efm.drop_function(fn_name)
139+
try:
140+
await cb_env.efm.drop_function(fn_name)
141+
except EventingFunctionNotFoundException:
142+
continue
137143
await cb_env.try_n_times_till_exception(10,
138144
1,
139145
cb_env.efm.get_function,
@@ -148,18 +154,25 @@ async def undeploy_and_drop_eventing_function(self, cb_env):
148154
await self._wait_until_status(
149155
cb_env, 15, 2, EventingFunctionState.Undeployed, self.TEST_EVT_NAME
150156
)
151-
await cb_env.efm.drop_function(self.TEST_EVT_NAME)
157+
try:
158+
await cb_env.efm.drop_function(self.TEST_EVT_NAME)
159+
except EventingFunctionNotFoundException:
160+
pass
152161

153162
@pytest_asyncio.fixture()
154163
async def create_and_drop_eventing_function(self, cb_env):
155164
await cb_env.efm.upsert_function(self.BASIC_FUNC)
156165
yield
157-
await cb_env.efm.drop_function(self.BASIC_FUNC.name)
158-
await cb_env.try_n_times_till_exception(10,
159-
1,
160-
cb_env.efm.get_function,
161-
self.BASIC_FUNC.name,
162-
EventingFunctionNotFoundException)
166+
try:
167+
await cb_env.efm.drop_function(self.BASIC_FUNC.name)
168+
except EventingFunctionNotFoundException:
169+
pass
170+
else:
171+
await cb_env.try_n_times_till_exception(10,
172+
1,
173+
cb_env.efm.get_function,
174+
self.BASIC_FUNC.name,
175+
EventingFunctionNotFoundException)
163176

164177
async def _wait_until_status(self,
165178
cb_env, # type: TestEnvironment

couchbase/tests/eventingmgmt_t.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ class EventingManagementTestSuite:
7777
def create_and_drop_eventing_function(self, cb_env):
7878
cb_env.efm.upsert_function(cb_env.BASIC_FUNC)
7979
yield
80-
cb_env.efm.drop_function(cb_env.BASIC_FUNC.name)
81-
TestEnvironment.try_n_times_till_exception(10,
82-
1,
83-
cb_env.efm.get_function,
84-
cb_env.BASIC_FUNC.name,
85-
EventingFunctionNotFoundException)
80+
try:
81+
cb_env.efm.drop_function(cb_env.BASIC_FUNC.name)
82+
except EventingFunctionNotFoundException:
83+
pass
84+
else:
85+
TestEnvironment.try_n_times_till_exception(10,
86+
1,
87+
cb_env.efm.get_function,
88+
cb_env.BASIC_FUNC.name,
89+
EventingFunctionNotFoundException)
8690

8791
@pytest.fixture()
8892
def create_eventing_function(self, cb_env):
@@ -92,7 +96,10 @@ def create_eventing_function(self, cb_env):
9296
def drop_eventing_functions(self, cb_env):
9397
yield
9498
for fn_name in cb_env.function_names:
95-
cb_env.efm.drop_function(fn_name)
99+
try:
100+
cb_env.efm.drop_function(fn_name)
101+
except EventingFunctionNotFoundException:
102+
continue
96103
TestEnvironment.try_n_times_till_exception(10,
97104
1,
98105
cb_env.efm.get_function,
@@ -105,12 +112,16 @@ def undeploy_and_drop_eventing_function(self, cb_env):
105112
yield
106113
cb_env.efm.undeploy_function(cb_env.TEST_EVT_NAME)
107114
cb_env.wait_until_status(15, 2, EventingFunctionState.Undeployed, cb_env.BASIC_FUNC.name)
108-
cb_env.efm.drop_function(cb_env.TEST_EVT_NAME)
109-
TestEnvironment.try_n_times_till_exception(10,
110-
1,
111-
cb_env.efm.get_function,
112-
cb_env.BASIC_FUNC.name,
113-
EventingFunctionNotFoundException)
115+
try:
116+
cb_env.efm.drop_function(cb_env.TEST_EVT_NAME)
117+
except EventingFunctionNotFoundException:
118+
pass
119+
else:
120+
TestEnvironment.try_n_times_till_exception(10,
121+
1,
122+
cb_env.efm.get_function,
123+
cb_env.BASIC_FUNC.name,
124+
EventingFunctionNotFoundException)
114125

115126
@pytest.mark.usefixtures('drop_eventing_functions')
116127
def test_constant_bindings(self, cb_env):

0 commit comments

Comments
 (0)