You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/02/10 00:37:08 UTC
[couchdb] branch main updated (bf0903087 -> 8bc485d9b)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
from bf0903087 Remove all javascript tests
new 0a49ffcda Convert ExUnit tests back to EUnit
new a73388452 Disable execution of ExUnit tests
new c79d82f10 Fix Dreyfus Elixir test suite
new 4185bc094 Document the `dreyfus-test` `make` target
new 8bc485d9b Improve directory structure for Dreyfus EUnit tests
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
Makefile | 13 ++-
Makefile.win | 13 ++-
README-DEV.rst | 15 +++
src/couch/test/eunit/couch_compress_tests.erl | 128 +++++++++++++++++++++
src/couch/test/eunit/same_site_cookie_tests.erl | 88 ++++++++++++++
src/couch/test/exunit/couch_compress_tests.exs | 113 ------------------
src/couch/test/exunit/same_site_cookie_tests.exs | 44 -------
src/couch/test/exunit/test_helper.exs | 2 -
src/dreyfus/test/elixir/mix.exs | 2 +-
src/dreyfus/test/elixir/mix.lock | 6 +-
src/dreyfus/test/elixir/run | 4 -
.../test/elixir/test/config/test-config.ini | 2 +
src/dreyfus/test/elixir/test/test_helper.exs | 10 +-
.../{ => eunit}/dreyfus_blacklist_await_test.erl | 0
.../{ => eunit}/dreyfus_blacklist_request_test.erl | 0
.../test/{ => eunit}/dreyfus_config_test.erl | 0
.../test/{ => eunit}/dreyfus_purge_test.erl | 0
src/dreyfus/test/{ => eunit}/dreyfus_test_util.erl | 0
18 files changed, 267 insertions(+), 173 deletions(-)
create mode 100644 src/couch/test/eunit/couch_compress_tests.erl
create mode 100644 src/couch/test/eunit/same_site_cookie_tests.erl
delete mode 100644 src/couch/test/exunit/couch_compress_tests.exs
delete mode 100644 src/couch/test/exunit/same_site_cookie_tests.exs
delete mode 100644 src/couch/test/exunit/test_helper.exs
delete mode 100755 src/dreyfus/test/elixir/run
create mode 100644 src/dreyfus/test/elixir/test/config/test-config.ini
rename src/dreyfus/test/{ => eunit}/dreyfus_blacklist_await_test.erl (100%)
rename src/dreyfus/test/{ => eunit}/dreyfus_blacklist_request_test.erl (100%)
rename src/dreyfus/test/{ => eunit}/dreyfus_config_test.erl (100%)
rename src/dreyfus/test/{ => eunit}/dreyfus_purge_test.erl (100%)
rename src/dreyfus/test/{ => eunit}/dreyfus_test_util.erl (100%)
[couchdb] 02/05: Disable execution of ExUnit tests
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit a733884522394fdebd1c5d2198bdd4a7bd8f9c7b
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Thu Feb 9 17:12:53 2023 +0100
Disable execution of ExUnit tests
Currently, there are no ExUnit tests so do not try to run them.
---
Makefile | 1 -
Makefile.win | 1 -
2 files changed, 2 deletions(-)
diff --git a/Makefile b/Makefile
index 146087723..fc9c5ccb3 100644
--- a/Makefile
+++ b/Makefile
@@ -152,7 +152,6 @@ escriptize: couch
.PHONY: check
# target: check - Test everything
check: all
- @$(MAKE) exunit
@$(MAKE) eunit
@$(MAKE) mango-test
@$(MAKE) elixir-suite
diff --git a/Makefile.win b/Makefile.win
index a6acaa161..ec581afc3 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -134,7 +134,6 @@ fauxton: share\www
.PHONY: check
# target: check - Test everything
check: all
- @$(MAKE) exunit
@$(MAKE) eunit
@$(MAKE) mango-test
@$(MAKE) elixir-suite
[couchdb] 03/05: Fix Dreyfus Elixir test suite
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit c79d82f104eedd1b2e1af5b1a4b3db63e57615d0
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Thu Feb 9 22:08:33 2023 +0100
Fix Dreyfus Elixir test suite
Remove the old shell script that would drive the testing process
and rather integrate it as a dedicated `make` target, `dreyfus-test`.
---
Makefile | 12 ++++++++++++
Makefile.win | 12 ++++++++++++
src/dreyfus/test/elixir/mix.exs | 2 +-
src/dreyfus/test/elixir/mix.lock | 6 +++---
src/dreyfus/test/elixir/run | 4 ----
src/dreyfus/test/elixir/test/config/test-config.ini | 2 ++
src/dreyfus/test/elixir/test/test_helper.exs | 10 ++++++----
7 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index fc9c5ccb3..cdaaeadad 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@ include version.mk
REBAR?=$(shell echo `pwd`/bin/rebar)
ERLFMT?=$(shell echo `pwd`/bin/erlfmt)
+ROOT=$(shell pwd)
# Handle the following scenarios:
# 1. When building from a tarball, use version.mk.
@@ -270,6 +271,17 @@ elixir-suite: elixir-init devclean
--erlang-config rel/files/eunit.config \
--no-eval 'mix test --trace --include test/elixir/test/config/suite.elixir --exclude test/elixir/test/config/skip.elixir'
+src/dreyfus/test/elixir/deps:
+ @cd src/dreyfus/test/elixir && mix deps.get
+
+.PHONY: dreyfus-test
+# target: dreyfus-test - Run Dreyfus tests, requires a running Clouseau instance
+dreyfus-test: export MIX_ENV=integration
+dreyfus-test: elixir-init devclean src/dreyfus/test/elixir/deps
+ @cd src/dreyfus/test/elixir && $(ROOT)/dev/run -n 1 -q -a adm:pass \
+ --locald-config test/config/test-config.ini \
+ --no-eval 'mix test --trace $(EXUNIT_OPTS)'
+
.PHONY: elixir-source-checks
elixir-source-checks: export MIX_ENV=integration
elixir-source-checks: elixir-init
diff --git a/Makefile.win b/Makefile.win
index ec581afc3..4432276ad 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -22,6 +22,7 @@ PYTHON=python.exe
ERLFMT?=$(CURDIR)\bin\erlfmt.cmd
MAKE=make -f Makefile.win
# REBAR?=$(shell where rebar.cmd)
+ROOT=$(CURDIR)
# Handle the following scenarios:
# 1. When building from a tarball, use version.mk.
@@ -241,6 +242,17 @@ elixir-suite: elixir-init elixir-check-formatted elixir-credo devclean
--erlang-config rel/files/eunit.config \
--no-eval 'mix test --trace --include test\elixir\test\config\suite.elixir --exclude test\elixir\test\config\skip.elixir'
+src\dreyfus\test\elixir\deps:
+ @cd src\dreyfus\test\elixir && mix deps.get
+
+.PHONY: dreyfus-test
+# target: dreyfus-test - Run Dreyfus tests, requires a running Clouseau instance
+dreyfus-test: export MIX_ENV=integration
+dreyfus-test: elixir-init devclean src\dreyfus\test\elixir\deps
+ @cd src\dreyfus\test\elixir && $(ROOT)\dev\run -n 1 -q -a adm:pass \
+ --locald-config test\config\test-config.ini \
+ --no-eval 'mix test --trace $(EXUNIT_OPTS)'
+
.PHONY: elixir-check-formatted
elixir-check-formatted: elixir-init
@mix format --check-formatted
diff --git a/src/dreyfus/test/elixir/mix.exs b/src/dreyfus/test/elixir/mix.exs
index 9b0f642dd..f77d9d6a3 100644
--- a/src/dreyfus/test/elixir/mix.exs
+++ b/src/dreyfus/test/elixir/mix.exs
@@ -23,7 +23,7 @@ defmodule Foo.Mixfile do
[
# {:dep_from_hexpm, "~> 0.3.0"},
{:httpotion, "~> 3.0"},
- {:jiffy, "~> 0.14.11"}
+ {:jiffy, path: Path.expand("../../../jiffy", __DIR__)}
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
]
end
diff --git a/src/dreyfus/test/elixir/mix.lock b/src/dreyfus/test/elixir/mix.lock
index ed51e5312..51d765b15 100644
--- a/src/dreyfus/test/elixir/mix.lock
+++ b/src/dreyfus/test/elixir/mix.lock
@@ -1,5 +1,5 @@
%{
- "httpotion": {:hex, :httpotion, "3.1.0", "14d20d9b0ce4e86e253eb91e4af79e469ad949f57a5d23c0a51b2f86559f6589", [:mix], [{:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: false]}], "hexpm"},
- "ibrowse": {:hex, :ibrowse, "4.4.1", "2b7d0637b0f8b9b4182de4bd0f2e826a4da2c9b04898b6e15659ba921a8d6ec2", [:rebar3], [], "hexpm"},
- "jiffy": {:hex, :jiffy, "0.14.13", "225a9a35e26417832c611526567194b4d3adc4f0dfa5f2f7008f4684076f2a01", [:rebar3], [], "hexpm"},
+ "httpotion": {:hex, :httpotion, "3.1.0", "14d20d9b0ce4e86e253eb91e4af79e469ad949f57a5d23c0a51b2f86559f6589", [:mix], [{:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: false]}], "hexpm", "2e1f3da5398258f67be9522793c2ccef157d3c9f7a4f69ec8e87184393efe9e0"},
+ "ibrowse": {:hex, :ibrowse, "4.4.1", "2b7d0637b0f8b9b4182de4bd0f2e826a4da2c9b04898b6e15659ba921a8d6ec2", [:rebar3], [], "hexpm", "1e86c591dbc6d270632625534986beca30813af7ce784e742e5fc38e342c29b3"},
+ "jiffy": {:hex, :jiffy, "0.14.13", "225a9a35e26417832c611526567194b4d3adc4f0dfa5f2f7008f4684076f2a01", [:rebar3], [], "hexpm", "be5f0b124d03284b79fa90e07c3cf7a04be1a6111e97e0c9059e3cc0c7aac11a"},
}
diff --git a/src/dreyfus/test/elixir/run b/src/dreyfus/test/elixir/run
deleted file mode 100755
index 66a5947b7..000000000
--- a/src/dreyfus/test/elixir/run
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash -e
-cd "$(dirname "$0")"
-mix deps.get
-mix test --trace
diff --git a/src/dreyfus/test/elixir/test/config/test-config.ini b/src/dreyfus/test/elixir/test/config/test-config.ini
new file mode 100644
index 000000000..8ceff6fd1
--- /dev/null
+++ b/src/dreyfus/test/elixir/test/config/test-config.ini
@@ -0,0 +1,2 @@
+[dreyfus]
+name = clouseau@127.0.0.1
diff --git a/src/dreyfus/test/elixir/test/test_helper.exs b/src/dreyfus/test/elixir/test/test_helper.exs
index 5f9c5833d..81083e910 100644
--- a/src/dreyfus/test/elixir/test/test_helper.exs
+++ b/src/dreyfus/test/elixir/test/test_helper.exs
@@ -1,4 +1,6 @@
-Code.require_file "../../../../couchdb/test/elixir/lib/couch.ex", __DIR__
-Code.require_file "../../../../couchdb/test/elixir/test/test_helper.exs", __DIR__
-Code.require_file "../../../../couchdb/test/elixir/test/support/couch_test_case.ex", __DIR__
-Code.require_file "../../../../couchdb/test/elixir/lib/couch/dbtest.ex", __DIR__
+Code.require_file "../../../../../test/elixir/lib/couch.ex", __DIR__
+Code.require_file "../../../../../test/elixir/lib/couch/dbtest.ex", __DIR__
+Code.require_file "../../../../../test/elixir/test/support/couch_test_case.ex", __DIR__
+Code.require_file "../../../../../test/elixir/lib/suite.ex", __DIR__
+Code.require_file "../../../../../test/elixir/test/test_helper.exs", __DIR__
+Couch.Test.Suite.start()
[couchdb] 05/05: Improve directory structure for Dreyfus EUnit tests
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 8bc485d9bed7d9a68140f330869cd67ca874c756
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Thu Feb 9 23:55:29 2023 +0100
Improve directory structure for Dreyfus EUnit tests
---
src/dreyfus/test/{ => eunit}/dreyfus_blacklist_await_test.erl | 0
src/dreyfus/test/{ => eunit}/dreyfus_blacklist_request_test.erl | 0
src/dreyfus/test/{ => eunit}/dreyfus_config_test.erl | 0
src/dreyfus/test/{ => eunit}/dreyfus_purge_test.erl | 0
src/dreyfus/test/{ => eunit}/dreyfus_test_util.erl | 0
5 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/src/dreyfus/test/dreyfus_blacklist_await_test.erl b/src/dreyfus/test/eunit/dreyfus_blacklist_await_test.erl
similarity index 100%
rename from src/dreyfus/test/dreyfus_blacklist_await_test.erl
rename to src/dreyfus/test/eunit/dreyfus_blacklist_await_test.erl
diff --git a/src/dreyfus/test/dreyfus_blacklist_request_test.erl b/src/dreyfus/test/eunit/dreyfus_blacklist_request_test.erl
similarity index 100%
rename from src/dreyfus/test/dreyfus_blacklist_request_test.erl
rename to src/dreyfus/test/eunit/dreyfus_blacklist_request_test.erl
diff --git a/src/dreyfus/test/dreyfus_config_test.erl b/src/dreyfus/test/eunit/dreyfus_config_test.erl
similarity index 100%
rename from src/dreyfus/test/dreyfus_config_test.erl
rename to src/dreyfus/test/eunit/dreyfus_config_test.erl
diff --git a/src/dreyfus/test/dreyfus_purge_test.erl b/src/dreyfus/test/eunit/dreyfus_purge_test.erl
similarity index 100%
rename from src/dreyfus/test/dreyfus_purge_test.erl
rename to src/dreyfus/test/eunit/dreyfus_purge_test.erl
diff --git a/src/dreyfus/test/dreyfus_test_util.erl b/src/dreyfus/test/eunit/dreyfus_test_util.erl
similarity index 100%
rename from src/dreyfus/test/dreyfus_test_util.erl
rename to src/dreyfus/test/eunit/dreyfus_test_util.erl
[couchdb] 01/05: Convert ExUnit tests back to EUnit
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 0a49ffcdac0374633070ccc28d37cd5ac1a2af10
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Thu Jan 26 22:19:07 2023 +0100
Convert ExUnit tests back to EUnit
ExUnit tests were not fully adopted and also became abandoned.
Improve the situation by translating those few ExUnit tests to
EUnit ones.
---
src/couch/test/eunit/couch_compress_tests.erl | 128 +++++++++++++++++++++++
src/couch/test/eunit/same_site_cookie_tests.erl | 88 ++++++++++++++++
src/couch/test/exunit/couch_compress_tests.exs | 113 --------------------
src/couch/test/exunit/same_site_cookie_tests.exs | 44 --------
src/couch/test/exunit/test_helper.exs | 2 -
5 files changed, 216 insertions(+), 159 deletions(-)
diff --git a/src/couch/test/eunit/couch_compress_tests.erl b/src/couch/test/eunit/couch_compress_tests.erl
new file mode 100644
index 000000000..3d11be41a
--- /dev/null
+++ b/src/couch/test/eunit/couch_compress_tests.erl
@@ -0,0 +1,128 @@
+% 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.
+
+-module(couch_compress_tests).
+
+-include_lib("couch/include/couch_eunit.hrl").
+
+-define(TERM, {[{a, 1}, {b, 2}, {c, 3}, {d, 4}, {e, 5}]}).
+
+-define(NONE,
+ <<131, 104, 1, 108, 0, 0, 0, 5, 104, 2, 100, 0, 1, 97, 97, 1, 104, 2, 100, 0, 1, 98, 97, 2, 104,
+ 2, 100, 0, 1, 99, 97, 3, 104, 2, 100, 0, 1, 100, 97, 4, 104, 2, 100, 0, 1, 101, 97, 5, 106>>
+).
+-define(DEFLATE,
+ <<131, 80, 0, 0, 0, 48, 120, 218, 203, 96, 204, 97, 96, 96, 96, 205, 96, 74, 97, 96, 76, 76,
+ 100, 4, 211, 73, 137, 76, 96, 58, 57, 145, 25, 76, 167, 36, 178, 128, 233, 212, 68, 214, 44,
+ 0, 212, 169, 9, 51>>
+).
+-define(SNAPPY,
+ <<1, 49, 64, 131, 104, 1, 108, 0, 0, 0, 5, 104, 2, 100, 0, 1, 97, 97, 1, 104, 1, 8, 8, 98, 97,
+ 2, 5, 8, 8, 99, 97, 3, 5, 8, 44, 100, 97, 4, 104, 2, 100, 0, 1, 101, 97, 5, 106>>
+).
+-define(SNAPPY_BIGENDIAN,
+ <<1, 49, 60, 131, 104, 1, 108, 0, 0, 0, 5, 104, 2, 100, 0, 1, 97, 97, 1, 5, 8, 8, 98, 97, 2, 5,
+ 8, 8, 99, 97, 3, 5, 8, 44, 100, 97, 4, 104, 2, 100, 0, 1, 101, 97, 5, 106>>
+).
+-define(CORRUPT, <<2, 12, 85, 06>>).
+
+-define(DEFLATE_COMPRESSION, {deflate, 9}).
+-define(DEFLATE_COMPRESSION_ZERO, {deflate, 0}).
+
+couch_compress_test_() ->
+ {
+ "couch compress tests",
+ [
+ fun t_compress/0,
+ fun t_decompress/0,
+ fun t_recompress/0,
+ fun t_is_compressed/0,
+ fun t_uncompressed_size/0
+ ]
+ }.
+
+t_compress() ->
+ ?assertEqual(?NONE, couch_compress:compress(?TERM, none)),
+ ?assertNotEqual(?NONE, couch_compress:compress(?TERM, ?DEFLATE_COMPRESSION)),
+ ?assertNotEqual(?NONE, couch_compress:compress(?TERM, snappy)),
+
+ % assert that compressed output is smaller than uncompressed output
+ ?assert(bit_size(couch_compress:compress(?TERM, ?DEFLATE_COMPRESSION)) < bit_size(?NONE)),
+ ?assert(bit_size(couch_compress:compress(?TERM, snappy)) < bit_size(?NONE)).
+
+t_decompress() ->
+ ?assertEqual(?TERM, couch_compress:decompress(?NONE)),
+ ?assertEqual(?TERM, couch_compress:decompress(?DEFLATE)),
+ ?assertEqual(?TERM, couch_compress:decompress(?SNAPPY)),
+ ?assertEqual(?TERM, couch_compress:decompress(?SNAPPY_BIGENDIAN)),
+ ?assertError(invalid_compression, couch_compress:decompress(?CORRUPT)).
+
+t_recompress() ->
+ Result1 = ?NONE,
+
+ % none -> deflate
+ Result2 = couch_compress:compress(Result1, ?DEFLATE_COMPRESSION),
+ ?assert(couch_compress:is_compressed(Result2, ?DEFLATE_COMPRESSION)),
+
+ % deflate -> snappy
+ Result3 = couch_compress:compress(Result2, snappy),
+ ?assert(couch_compress:is_compressed(Result3, snappy)),
+
+ % snappy -> none
+ Result4 = couch_compress:compress(Result3, none),
+ ?assert(couch_compress:is_compressed(Result4, none)),
+
+ % none -> snappy
+ Result5 = couch_compress:compress(Result4, snappy),
+ ?assert(couch_compress:is_compressed(Result5, snappy)),
+
+ % snappy -> deflate
+ Result6 = couch_compress:compress(Result5, ?DEFLATE_COMPRESSION),
+ ?assert(couch_compress:is_compressed(Result6, ?DEFLATE_COMPRESSION)),
+
+ % deflate -> none
+ Result7 = couch_compress:compress(Result6, none),
+ ?assert(couch_compress:is_compressed(Result7, none)).
+
+t_is_compressed() ->
+ ?assert(couch_compress:is_compressed(?NONE, none)),
+ ?assert(couch_compress:is_compressed(?DEFLATE, ?DEFLATE_COMPRESSION)),
+ ?assert(couch_compress:is_compressed(?SNAPPY, snappy)),
+ ?assert(couch_compress:is_compressed(?SNAPPY_BIGENDIAN, snappy)),
+ ?assertNot(couch_compress:is_compressed(?NONE, ?DEFLATE_COMPRESSION_ZERO)),
+ ?assertNot(couch_compress:is_compressed(?NONE, ?DEFLATE_COMPRESSION)),
+ ?assertNot(couch_compress:is_compressed(?NONE, snappy)),
+ ?assertNot(couch_compress:is_compressed(?DEFLATE, none)),
+ ?assertNot(couch_compress:is_compressed(?DEFLATE, snappy)),
+ ?assertNot(couch_compress:is_compressed(?SNAPPY, none)),
+ ?assertNot(couch_compress:is_compressed(?SNAPPY, ?DEFLATE_COMPRESSION)),
+ ?assertNot(couch_compress:is_compressed(?SNAPPY_BIGENDIAN, none)),
+ ?assertNot(couch_compress:is_compressed(?SNAPPY_BIGENDIAN, ?DEFLATE_COMPRESSION)),
+
+ ?assertError(invalid_compression, couch_compress:is_compressed(?CORRUPT, none)),
+ ?assertError(invalid_compression, couch_compress:is_compressed(?CORRUPT, ?DEFLATE_COMPRESSION)),
+ ?assertError(invalid_compression, couch_compress:is_compressed(?CORRUPT, snappy)).
+
+t_uncompressed_size() ->
+ ?assertEqual(49, couch_compress:uncompressed_size(?NONE)),
+ ?assertEqual(49, couch_compress:uncompressed_size(?DEFLATE)),
+ ?assertEqual(49, couch_compress:uncompressed_size(?SNAPPY)),
+ ?assertEqual(49, couch_compress:uncompressed_size(?SNAPPY_BIGENDIAN)),
+
+ ?assertEqual(
+ 5,
+ couch_compress:uncompressed_size(
+ couch_compress:compress(x, ?DEFLATE_COMPRESSION)
+ )
+ ),
+
+ ?assertError(invalid_compression, couch_compress:uncompressed_size(?CORRUPT)).
diff --git a/src/couch/test/eunit/same_site_cookie_tests.erl b/src/couch/test/eunit/same_site_cookie_tests.erl
new file mode 100644
index 000000000..9ae56b27e
--- /dev/null
+++ b/src/couch/test/eunit/same_site_cookie_tests.erl
@@ -0,0 +1,88 @@
+% 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.
+
+-module(same_site_cookie_tests).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+
+-define(USER, "jan").
+-define(PASS, "apple").
+
+-define(PERSIST, false).
+
+setup() ->
+ Hashed = couch_passwords:hash_admin_password(?PASS),
+ ok = config:set("admins", ?USER, ?b2l(Hashed), ?PERSIST),
+ Addr = config:get("httpd", "bind_address", "127.0.0.1"),
+ Port = integer_to_list(mochiweb_socket_server:get(couch_httpd, port)),
+ "http://" ++ Addr ++ ":" ++ Port.
+
+teardown(_BaseUri) ->
+ ok = config:delete("couch_httpd_auth", "same_site", ?PERSIST),
+ ok = config:delete("admins", ?USER, ?PERSIST).
+
+get_cookie(BaseUri, User, Password) ->
+ {ok, _, Headers, _} = test_request:post(
+ BaseUri ++ "/_session",
+ [{"Content-Type", "application/json"}],
+ couch_util:json_encode(#{username => ?l2b(User), password => ?l2b(Password)})
+ ),
+ proplists:get_value("Set-Cookie", Headers).
+
+same_site_cookie_test_() ->
+ {
+ "same-site cookie tests",
+ {
+ setup,
+ fun test_util:start_couch/0,
+ fun test_util:stop_couch/1,
+ {
+ foreach,
+ fun setup/0,
+ fun teardown/1,
+ [
+ ?TDEF_FE(same_site_none),
+ ?TDEF_FE(same_site_missing),
+ ?TDEF_FE(same_site_strict),
+ ?TDEF_FE(same_site_lax),
+ ?TDEF_FE(same_site_invalid)
+ ]
+ }
+ }
+ }.
+
+same_site_none(BaseUri) ->
+ ok = config:set("couch_httpd_auth", "same_site", "None", ?PERSIST),
+ Cookie = get_cookie(BaseUri, ?USER, ?PASS),
+ ?assertNotEqual(nomatch, string:find(Cookie, "; SameSite=None")).
+
+same_site_missing(BaseUri) ->
+ ok = config:set("couch_httpd_auth", "same_site", "", ?PERSIST),
+ Cookie = get_cookie(BaseUri, ?USER, ?PASS),
+ ?assertNotEqual(undefined, Cookie),
+ ?assertEqual(nomatch, string:find(Cookie, "; SameSite=")).
+
+same_site_strict(BaseUri) ->
+ ok = config:set("couch_httpd_auth", "same_site", "Strict", ?PERSIST),
+ Cookie = get_cookie(BaseUri, ?USER, ?PASS),
+ ?assertNotEqual(nomatch, string:find(Cookie, "; SameSite=Strict")).
+
+same_site_lax(BaseUri) ->
+ ok = config:set("couch_httpd_auth", "same_site", "Lax", ?PERSIST),
+ Cookie = get_cookie(BaseUri, ?USER, ?PASS),
+ ?assertNotEqual(nomatch, string:find(Cookie, "; SameSite=Lax")).
+
+same_site_invalid(BaseUri) ->
+ ok = config:set("couch_httpd_auth", "same_site", "Invalid", ?PERSIST),
+ Cookie = get_cookie(BaseUri, ?USER, ?PASS),
+ ?assertEqual(nomatch, string:find(Cookie, "; SameSite=")).
diff --git a/src/couch/test/exunit/couch_compress_tests.exs b/src/couch/test/exunit/couch_compress_tests.exs
deleted file mode 100644
index 5550e0661..000000000
--- a/src/couch/test/exunit/couch_compress_tests.exs
+++ /dev/null
@@ -1,113 +0,0 @@
-defmodule Couch.Test.CouchCompress do
- use Couch.Test.ExUnit.Case
- alias Couch.Test.Utils
-
- import Utils
-
- @term {[{:a, 1}, {:b, 2}, {:c, 3}, {:d, 4}, {:e, 5}]}
-
- @none <<131, 104, 1, 108, 0, 0, 0, 5, 104, 2, 100, 0, 1, 97, 97, 1, 104, 2, 100, 0, 1,
- 98, 97, 2, 104, 2, 100, 0, 1, 99, 97, 3, 104, 2, 100, 0, 1, 100, 97, 4, 104, 2,
- 100, 0, 1, 101, 97, 5, 106>>
-
- @deflate <<131, 80, 0, 0, 0, 48, 120, 218, 203, 96, 204, 97, 96, 96, 96, 205, 96, 74,
- 97, 96, 76, 76, 100, 4, 211, 73, 137, 76, 96, 58, 57, 145, 25, 76, 167, 36,
- 178, 128, 233, 212, 68, 214, 44, 0, 212, 169, 9, 51>>
-
- @snappy <<1, 49, 64, 131, 104, 1, 108, 0, 0, 0, 5, 104, 2, 100, 0, 1, 97, 97, 1, 104, 1,
- 8, 8, 98, 97, 2, 5, 8, 8, 99, 97, 3, 5, 8, 44, 100, 97, 4, 104, 2, 100, 0, 1,
- 101, 97, 5, 106>>
-
- @snappy_bigendian <<1, 49, 60, 131, 104, 1, 108, 0, 0, 0, 5, 104, 2, 100, 0, 1, 97, 97,
- 1, 5, 8, 8, 98, 97, 2, 5, 8, 8, 99, 97, 3, 5, 8, 44, 100, 97, 4,
- 104, 2, 100, 0, 1, 101, 97, 5, 106>>
-
- @corrupt <<2, 12, 85, 06>>
-
- describe "couch_compress" do
- test "compress" do
- assert @none === :couch_compress.compress(@term, :none)
- assert @none !== :couch_compress.compress(@term, {:deflate, 9})
- assert @none !== :couch_compress.compress(@term, :snappy)
-
- # assert that compressed output is smaller than uncompressed input
- assert bit_size(:couch_compress.compress(@term, {:deflate, 9})) < bit_size(@none)
- assert bit_size(:couch_compress.compress(@term, :snappy)) < bit_size(@none)
- end
-
- test "decompress" do
- assert @term === :couch_compress.decompress(@none)
- assert @term === :couch_compress.decompress(@deflate)
- assert @term === :couch_compress.decompress(@snappy)
- assert @term === :couch_compress.decompress(@snappy_bigendian)
- assert catch_error(:couch_compress.decompress(@corrupt)) == :invalid_compression
- end
-
- test "recompress" do
- res = @none
-
- # none -> deflate
- res = :couch_compress.compress(res, {:deflate, 9})
- assert :couch_compress.is_compressed(res, {:deflate, 9})
-
- # deflate -> snappy
- res = :couch_compress.compress(res, :snappy)
- assert :couch_compress.is_compressed(res, :snappy)
-
- # snappy -> none
- res = :couch_compress.compress(res, :none)
- assert :couch_compress.is_compressed(res, :none)
-
- # none -> snappy
- res = :couch_compress.compress(res, :snappy)
- assert :couch_compress.is_compressed(res, :snappy)
-
- # snappy -> deflate
- res = :couch_compress.compress(res, {:deflate, 9})
- assert :couch_compress.is_compressed(res, {:deflate, 9})
-
- # deflate -> none
- res = :couch_compress.compress(res, :none)
- assert :couch_compress.is_compressed(res, :none)
- end
-
- test "is_compressed" do
- assert :couch_compress.is_compressed(@none, :none)
- assert :couch_compress.is_compressed(@deflate, {:deflate, 9})
- assert :couch_compress.is_compressed(@snappy, :snappy)
- assert :couch_compress.is_compressed(@snappy_bigendian, :snappy)
- refute :couch_compress.is_compressed(@none, {:deflate, 0})
- refute :couch_compress.is_compressed(@none, {:deflate, 9})
- refute :couch_compress.is_compressed(@none, :snappy)
- refute :couch_compress.is_compressed(@deflate, :none)
- refute :couch_compress.is_compressed(@deflate, :snappy)
- refute :couch_compress.is_compressed(@snappy, :none)
- refute :couch_compress.is_compressed(@snappy, {:deflate, 9})
- refute :couch_compress.is_compressed(@snappy_bigendian, :none)
- refute :couch_compress.is_compressed(@snappy_bigendian, {:deflate, 9})
-
- assert catch_error(:couch_compress.is_compressed(@corrupt, :none)) ==
- :invalid_compression
-
- assert catch_error(:couch_compress.is_compressed(@corrupt, {:deflate, 9})) ==
- :invalid_compression
-
- assert catch_error(:couch_compress.is_compressed(@corrupt, :snappy)) ==
- :invalid_compression
- end
-
- test "uncompressed_size" do
- assert :couch_compress.uncompressed_size(@none) === 49
- assert :couch_compress.uncompressed_size(@deflate) === 49
- assert :couch_compress.uncompressed_size(@snappy) === 49
- assert :couch_compress.uncompressed_size(@snappy_bigendian) === 49
-
- assert :couch_compress.uncompressed_size(
- :couch_compress.compress(:x, {:deflate, 9})
- ) === 5
-
- assert catch_error(:couch_compress.uncompressed_size(@corrupt)) ==
- :invalid_compression
- end
- end
-end
diff --git a/src/couch/test/exunit/same_site_cookie_tests.exs b/src/couch/test/exunit/same_site_cookie_tests.exs
deleted file mode 100644
index bad32ada4..000000000
--- a/src/couch/test/exunit/same_site_cookie_tests.exs
+++ /dev/null
@@ -1,44 +0,0 @@
-defmodule SameSiteCookieTests do
- use CouchTestCase
-
- @moduletag :authentication
-
- def get_cookie(user, pass) do
- resp = Couch.post("/_session", body: %{:username => user, :password => pass})
-
- true = resp.body["ok"]
- resp.headers[:"set-cookie"]
- end
-
- @tag config: [{"admins", "jan", "apple"}, {"couch_httpd_auth", "same_site", "None"}]
- test "Set same_site None" do
- cookie = get_cookie("jan", "apple")
- assert cookie =~ "; SameSite=None"
- end
-
- @tag config: [{"admins", "jan", "apple"}, {"couch_httpd_auth", "same_site", ""}]
- test "same_site not set" do
- cookie = get_cookie("jan", "apple")
- assert cookie
- refute cookie =~ "; SameSite="
- end
-
- @tag config: [{"admins", "jan", "apple"}, {"couch_httpd_auth", "same_site", "Strict"}]
- test "Set same_site Strict" do
- cookie = get_cookie("jan", "apple")
- assert cookie =~ "; SameSite=Strict"
- end
-
- @tag config: [{"admins", "jan", "apple"}, {"couch_httpd_auth", "same_site", "Lax"}]
- test "Set same_site Lax" do
- cookie = get_cookie("jan", "apple")
- assert cookie =~ "; SameSite=Lax"
- end
-
- @tag config: [{"admins", "jan", "apple"}, {"couch_httpd_auth", "same_site", "Invalid"}]
- test "Set same_site invalid" do
- cookie = get_cookie("jan", "apple")
- assert cookie
- refute cookie =~ "; SameSite="
- end
-end
diff --git a/src/couch/test/exunit/test_helper.exs b/src/couch/test/exunit/test_helper.exs
deleted file mode 100644
index 314050085..000000000
--- a/src/couch/test/exunit/test_helper.exs
+++ /dev/null
@@ -1,2 +0,0 @@
-ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter])
-ExUnit.start()
[couchdb] 04/05: Document the `dreyfus-test` `make` target
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 4185bc094cb79592475589acbf5906901bb211b6
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Thu Feb 9 23:22:36 2023 +0100
Document the `dreyfus-test` `make` target
---
README-DEV.rst | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/README-DEV.rst b/README-DEV.rst
index e29d632f5..38124b9c7 100644
--- a/README-DEV.rst
+++ b/README-DEV.rst
@@ -225,6 +225,21 @@ following command::
make list-js-suites
+There is an additional Elixir-based integration test suite for
+Dreyfus, which is not run automatically by the ``check`` target but it
+could be done manually via the corresponding target::
+
+ make dreyfus-test
+
+Note that this requires a running Clouseau instance with the name
+`clouseau@127.0.0.1`. The easiest way to get it is to clone the
+[`cloudant-labs/clouseau`](https://github.com/cloudant-labs/clouseau)
+repository and launch it run there once all the prerequisites (JDK,
+Scala, and Maven) have been installed successfully, e.g.::
+
+ git clone https://github.com/cloudant-labs/clouseau
+ mvn -f clouseau/pom.xml scala:run
+
Code analyzer could be run by::
make dialyze