From f280ff896c5ff46dbe746a0116fb33dc05c40179 Mon Sep 17 00:00:00 2001 From: hulkoba Date: Wed, 19 Nov 2025 08:24:57 +0100 Subject: [PATCH 1/2] test: port 20-no-timeout from python to elixir --- test/elixir/test/config/suite.elixir | 3 ++ test/elixir/test/mango/20_no_timeout.exs | 39 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/elixir/test/mango/20_no_timeout.exs diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index b3fb950846..5c8c655a14 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -735,5 +735,8 @@ ], "IgnoreDesignDocsForAllDocsIndexTests": [ "should not return design docs" + ], + "LongRunningMangoTest": [ + "query does not time out" ] } diff --git a/test/elixir/test/mango/20_no_timeout.exs b/test/elixir/test/mango/20_no_timeout.exs new file mode 100644 index 0000000000..aa1dcecf12 --- /dev/null +++ b/test/elixir/test/mango/20_no_timeout.exs @@ -0,0 +1,39 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +defmodule LongRunningMangoTest do + use CouchTestCase + + @db_name "no-timeout" + + setup do + MangoDatabase.recreate(@db_name) + + 0..100_000 + |> Enum.reduce([], fn i, docs -> + docs = [%{"_id" => "#{i}", "another" => "field"} | docs] + + if rem(i, 20_000) == 0 do + MangoDatabase.save_docs(@db_name, docs) + [] + else + docs + end + end) + end + + test "query does not time out" do + selector = %{"_id" => %{"$gt" => 0}, "another" => "wrong"} + {:ok, docs} = MangoDatabase.find(@db_name, selector) + assert docs == [] + end +end From 209931164904efeb89dae6b439446091e40f62fc Mon Sep 17 00:00:00 2001 From: hulkoba Date: Wed, 19 Nov 2025 08:25:22 +0100 Subject: [PATCH 2/2] test: deprecate 20-no-timeout.py --- src/mango/test/20-no-timeout-test.py | 32 ---------------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/mango/test/20-no-timeout-test.py diff --git a/src/mango/test/20-no-timeout-test.py b/src/mango/test/20-no-timeout-test.py deleted file mode 100644 index 051b9a56c6..0000000000 --- a/src/mango/test/20-no-timeout-test.py +++ /dev/null @@ -1,32 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -import mango -import copy -import unittest - - -class LongRunningMangoTest(mango.DbPerClass): - def setUp(self): - super().setUp(db_per_test=True) - docs = [] - for i in range(100000): - docs.append({"_id": str(i), "another": "field"}) - if i % 20000 == 0: - self.db.save_docs(docs) - docs = [] - - # This test should run to completion and not timeout - def test_query_does_not_time_out(self): - selector = {"_id": {"$gt": 0}, "another": "wrong"} - docs = self.db.find(selector) - self.assertEqual(len(docs), 0)