summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2019-06-20 21:41:40 +0000
committerILYA Khlopotov <iilyak@apache.org>2019-07-29 11:24:37 +0000
commit74a1007af64dff8eb9d5860a11a5a591cd1668c3 (patch)
treeb88aa8867e861b1e976a97bbd1acb3e7c276da61
parentd0ccfa2b463b7087c1c3a766ca3ae963c1d1738d (diff)
downloadcouchdb-74a1007af64dff8eb9d5860a11a5a591cd1668c3.tar.gz
Unify runners for unit and integration tests
-rw-r--r--.credo.exs3
-rw-r--r--Makefile29
-rw-r--r--Makefile.win20
-rw-r--r--config/integration.exs12
-rw-r--r--mix.exs25
-rw-r--r--test/elixir/Makefile4
-rw-r--r--test/elixir/lib/utils.ex5
-rw-r--r--test/elixir/mix.exs37
-rw-r--r--test/elixir/mix.lock9
-rwxr-xr-xtest/elixir/run6
-rw-r--r--test/elixir/test/replication_test.exs4
-rw-r--r--test/elixir/test/test_helper.exs8
12 files changed, 68 insertions, 94 deletions
diff --git a/.credo.exs b/.credo.exs
index db301e4d0..2b84a5064 100644
--- a/.credo.exs
+++ b/.credo.exs
@@ -29,7 +29,8 @@
~r"/src/httpotion",
~r"/src/credo",
~r"/src/junit_formatter",
- ~r"/src/bunt"
+ ~r"/src/bunt",
+ ~r"/test/elixir/deps/"
]
},
#
diff --git a/Makefile b/Makefile
index 3d1be5149..58c814885 100644
--- a/Makefile
+++ b/Makefile
@@ -180,11 +180,7 @@ exunit: export MIX_ENV=test
exunit: export ERL_LIBS = $(shell pwd)/src
exunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js
-exunit: couch elixir-check-formatted elixir-credo
- @mix local.hex --force
- @mix local.rebar rebar ${REBAR} --force
- @mix deps.get
- @$(REBAR) setup_eunit 2> /dev/null
+exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
@mix test --trace $(EXUNIT_OPTS)
setup-eunit: export BUILDDIR = $(shell pwd)
@@ -226,34 +222,37 @@ python-black-update: .venv/bin/black
. dev/run rel/overlay/bin/couchup test/javascript/run
.PHONY: elixir
+elixir: export MIX_ENV=integration
elixir: elixir-init elixir-check-formatted elixir-credo devclean
- @dev/run -a adm:pass --no-eval 'test/elixir/run --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
+ @dev/run -a adm:pass --no-eval 'mix test --trace --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
.PHONY: elixir-init
elixir-init:
- @cd test/elixir && mix local.rebar --force && mix local.hex --force && mix deps.get
+ @mix local.rebar --force && mix local.hex --force && mix deps.get
.PHONY: elixir-cluster-without-quorum
-elixir-cluster-without-quorum: elixir-check-formatted elixir-credo devclean
+elixir-cluster-without-quorum: export MIX_ENV=integration
+elixir-cluster-without-quorum: elixir-init elixir-check-formatted elixir-credo devclean
@dev/run -n 3 -q -a adm:pass \
--degrade-cluster 2 \
- --no-eval 'test/elixir/run --only without_quorum_test $(EXUNIT_OPTS)'
+ --no-eval 'mix test --trace --only without_quorum_test $(EXUNIT_OPTS)'
.PHONY: elixir-cluster-with-quorum
-elixir-cluster-with-quorum: elixir-check-formatted elixir-credo devclean
+elixir-cluster-with-quorum: export MIX_ENV=integration
+elixir-cluster-with-quorum: elixir-init elixir-check-formatted elixir-credo devclean
@dev/run -n 3 -q -a adm:pass \
--degrade-cluster 1 \
- --no-eval 'test/elixir/run --only with_quorum_test $(EXUNIT_OPTS)'
+ --no-eval 'mix test --trace --only with_quorum_test $(EXUNIT_OPTS)'
.PHONY: elixir-check-formatted
-elixir-check-formatted:
- mix format --check-formatted
+elixir-check-formatted: elixir-init
+ @mix format --check-formatted
# Credo is a static code analysis tool for Elixir.
# We use it in our tests
.PHONY: elixir-credo
-elixir-credo:
- mix credo
+elixir-credo: elixir-init
+ @mix credo
.PHONY: javascript
# target: javascript - Run JavaScript test suites or specific ones defined by suites option
diff --git a/Makefile.win b/Makefile.win
index 2c4dc9821..7a5b5fca5 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -151,12 +151,8 @@ exunit: export MIX_ENV=test
exunit: export ERL_LIBS = $(shell echo %cd%)\src
exunit: export ERL_AFLAGS = -config $(shell echo %cd%)/rel/files/eunit.config
exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell echo %cd%)/bin/couchjs $(shell echo %cd%)/share/server/main.js
-exunit: couch elixir-check-formatted elixir-credo
- @mix local.hex --force
- @mix local.rebar rebar ${REBAR} --force
- @mix deps.get
- @$(REBAR) setup_eunit 2> nul
- @mix test --trace $(EXUNIT_OPTS)
+exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
+ @mix test --trace --exclude integration $(EXUNIT_OPTS)
setup-eunit: export BUILDDIR = $(shell pwd)
setup-eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config")
@@ -191,33 +187,33 @@ python-black-update: .venv/bin/black
.PHONY: elixir
elixir: elixir-init elixir-check-formatted elixir-credo devclean
- @dev\run -a adm:pass --no-eval 'test\elixir\run.cmd --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
+ @dev\run -a adm:pass --no-eval 'mix test --trace --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
.PHONY: elixir-init
elixir-init:
- @cd test/elixir && mix local.rebar --force && mix local.hex --force && mix deps.get
+ @mix local.rebar --force && mix local.hex --force && mix deps.get
.PHONY: elixir-cluster-without-quorum
elixir-cluster-without-quorum: elixir-check-formatted elixir-credo devclean
@dev\run -n 3 -q -a adm:pass \
--degrade-cluster 2 \
- --no-eval 'test\elixir\run.cmd --only without_quorum_test $(EXUNIT_OPTS)'
+ --no-eval 'mix test --trace --only without_quorum_test $(EXUNIT_OPTS)'
.PHONY: elixir-cluster-with-quorum
elixir-cluster-with-quorum: elixir-check-formatted elixir-credo devclean
@dev\run -n 3 -q -a adm:pass \
--degrade-cluster 1 \
- --no-eval 'test\elixir\run.cmd --only with_quorum_test $(EXUNIT_OPTS)'
+ --no-eval 'mix test --trace --only with_quorum_test $(EXUNIT_OPTS)'
.PHONY: elixir-check-formatted
elixir-check-formatted:
- @cd test\elixir && mix format --check-formatted
+ @mix format --check-formatted
# Credo is a static code analysis tool for Elixir.
# We use it in our tests
.PHONY: elixir-credo
elixir-credo:
- @cd test/elixir/ && mix credo
+ @mix credo
.PHONY: test-cluster-with-quorum
test-cluster-with-quorum: devclean
diff --git a/config/integration.exs b/config/integration.exs
new file mode 100644
index 000000000..c5a5ed24a
--- /dev/null
+++ b/config/integration.exs
@@ -0,0 +1,12 @@
+use Mix.Config
+
+config :logger,
+ backends: [:console],
+ compile_time_purge_level: :debug,
+ level: :debug
+
+config :kernel,
+ error_logger: false
+
+config :sasl,
+ sasl_error_logger: false
diff --git a/mix.exs b/mix.exs
index d9c8c2160..2e213aeb1 100644
--- a/mix.exs
+++ b/mix.exs
@@ -13,8 +13,8 @@ defmodule CouchDBTest.Mixfile do
start_permanent: Mix.env() == :prod,
build_embedded: Mix.env() == :prod,
deps: deps(),
- consolidate_protocols: Mix.env() not in [:test, :dev],
- test_paths: get_test_paths(),
+ consolidate_protocols: Mix.env() not in [:test, :dev, :integration],
+ test_paths: get_test_paths(Mix.env()),
elixirc_paths: elixirc_paths(Mix.env())
]
end
@@ -22,26 +22,39 @@ defmodule CouchDBTest.Mixfile do
# Run "mix help compile.app" to learn about applications.
def application do
[
- extra_applications: [:logger]
+ extra_applications: [:logger],
+ applications: [:httpotion]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["test/elixir/lib", "test/elixir/test/support"]
+ defp elixirc_paths(:integration), do: ["test/elixir/lib", "test/elixir/test/support"]
defp elixirc_paths(_), do: ["test/elixir/lib"]
# Run "mix help deps" to learn about dependencies.
defp deps() do
[
- {:httpotion, "~> 3.0", only: [:dev, :test], runtime: false},
+ {:httpotion, "~> 3.0", only: [:dev, :test, :integration], runtime: false},
{:jiffy, path: Path.expand("src/jiffy", __DIR__)},
{:ibrowse,
path: Path.expand("src/ibrowse", __DIR__), override: true, compile: false},
- {:credo, "~> 1.0.0", only: [:dev, :test], runtime: false}
+ {:credo, "~> 1.0.0", only: [:dev, :test, :integration], runtime: false}
]
end
- def get_test_paths do
+ def get_test_paths(:test) do
Path.wildcard("src/*/test/exunit") |> Enum.filter(&File.dir?/1)
end
+
+ def get_test_paths(:integration) do
+ integration_tests =
+ Path.wildcard("src/*/test/integration") |> Enum.filter(&File.dir?/1)
+
+ ["test/elixir/test" | integration_tests]
+ end
+
+ def get_test_paths(_) do
+ []
+ end
end
diff --git a/test/elixir/Makefile b/test/elixir/Makefile
index bfcf017d5..67ce2b427 100644
--- a/test/elixir/Makefile
+++ b/test/elixir/Makefile
@@ -1,2 +1,4 @@
+SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
all:
- mix test --trace
+ make -C ${SELF_DIR}../.. elixir
diff --git a/test/elixir/lib/utils.ex b/test/elixir/lib/utils.ex
index 4d3f33f69..3ecf878e7 100644
--- a/test/elixir/lib/utils.ex
+++ b/test/elixir/lib/utils.ex
@@ -1,11 +1,12 @@
defmodule Couch.Test.Utils do
require Record
@moduledoc "Helper functions for testing"
+ @project_root "#{__DIR__}/../../../"
Record.defrecord :user_ctx, Record.extract(
- :user_ctx, from_lib: "couch/include/couch_db.hrl")
+ :user_ctx, from: "#{@project_root}/src/couch/include/couch_db.hrl")
Record.defrecord :doc_info, Record.extract(
- :doc_info, from_lib: "couch/include/couch_db.hrl")
+ :doc_info, from: "#{@project_root}/src/couch/include/couch_db.hrl")
def random_name(prefix) do
time = :erlang.monotonic_time()
diff --git a/test/elixir/mix.exs b/test/elixir/mix.exs
deleted file mode 100644
index f04038ef3..000000000
--- a/test/elixir/mix.exs
+++ /dev/null
@@ -1,37 +0,0 @@
-defmodule Foo.Mixfile do
- use Mix.Project
-
- def project do
- [
- app: :foo,
- version: "0.1.0",
- elixir: "~> 1.6",
- elixirc_paths: elixirc_paths(Mix.env()),
- start_permanent: Mix.env() == :prod,
- deps: deps()
- ]
- end
-
- # Run "mix help compile.app" to learn about applications.
- def application do
- [
- extra_applications: [:logger]
- ]
- end
-
- # Specifies which paths to compile per environment.
- defp elixirc_paths(:test), do: ["lib", "test/support"]
- defp elixirc_paths(_), do: ["lib"]
-
- # Run "mix help deps" to learn about dependencies.
- defp deps do
- [
- # {:dep_from_hexpm, "~> 0.3.0"},
- {:httpotion, "~> 3.0"},
- {:jiffy, "~> 0.15.2"},
- {:credo, "~> 1.0.0", only: [:dev, :test], runtime: false},
- {:junit_formatter, "~> 3.0", only: [:test]}
- # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
- ]
- end
-end
diff --git a/test/elixir/mix.lock b/test/elixir/mix.lock
deleted file mode 100644
index 0fc391a92..000000000
--- a/test/elixir/mix.lock
+++ /dev/null
@@ -1,9 +0,0 @@
-%{
- "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
- "credo": {:hex, :credo, "1.0.0", "aaa40fdd0543a0cf8080e8c5949d8c25f0a24e4fc8c1d83d06c388f5e5e0ea42", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
- "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"},
- "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
- "jiffy": {:hex, :jiffy, "0.15.2", "de266c390111fd4ea28b9302f0bc3d7472468f3b8e0aceabfbefa26d08cd73b7", [:rebar3], [], "hexpm"},
- "junit_formatter": {:hex, :junit_formatter, "3.0.0", "13950d944dbd295da7d8cc4798b8faee808a8bb9b637c88069954eac078ac9da", [:mix], [], "hexpm"},
-}
diff --git a/test/elixir/run b/test/elixir/run
deleted file mode 100755
index a9c2efa4d..000000000
--- a/test/elixir/run
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash -e
-cd "$(dirname "$0")"
-mix local.hex --force
-mix local.rebar --force
-mix deps.get
-mix test --trace "$@"
diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index e98775fbd..a6e1303e6 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -1757,11 +1757,11 @@ defmodule ReplicationTest do
end
def get_att1_data do
- File.read!("test/data/lorem.txt")
+ File.read!(Path.expand("data/lorem.txt", __DIR__))
end
def get_att2_data do
- File.read!("test/data/lorem_b64.txt")
+ File.read!(Path.expand("data/lorem_b64.txt", __DIR__))
end
def cmp_json(lhs, rhs) when is_map(lhs) and is_map(rhs) do
diff --git a/test/elixir/test/test_helper.exs b/test/elixir/test/test_helper.exs
index ef71bbb1b..4bf65bcf6 100644
--- a/test/elixir/test/test_helper.exs
+++ b/test/elixir/test/test_helper.exs
@@ -2,12 +2,14 @@
# and skip certain tests that fail on jenkins.
exclude =
case System.get_env("BUILD_NUMBER") !== nil do
- true -> [pending: true, skip_on_jenkins: true]
- false -> [pending: true]
+ true -> [:pending, :skip_on_jenkins]
+ false -> [:pending]
end
+current_exclude = Keyword.get(ExUnit.configuration(), :exclude, [])
+
ExUnit.configure(
- exclude: exclude,
+ exclude: Enum.uniq(exclude ++ current_exclude),
formatters: [JUnitFormatter, ExUnit.CLIFormatter]
)