Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite fixes for Windows #1736

Merged
merged 3 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,27 @@ check: all
@$(MAKE) -f Makefile.win test-cluster-without-quorum
@$(MAKE) -f Makefile.win eunit
@$(MAKE) -f Makefile.win javascript
@$(MAKE) -f Makefile.win mango-test
# @$(MAKE) -f Makefile.win elixir


.PHONY: eunit
# target: eunit - Run EUnit tests, use EUNIT_OPTS to provide custom options
eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config")
eunit: export BUILDDIR = $(shell echo %cd%)
eunit: couch
@set ERL_AFLAGS="-config rel/files/eunit.config" && set BUILDDIR = $(shell echo %cd%) && $(REBAR) setup_eunit 2> nul
@set ERL_AFLAGS="-config rel/files/eunit.config" && set BUILDDIR = $(shell echo %cd%) && $(REBAR) -r eunit $(EUNIT_OPTS)
@$(REBAR) setup_eunit 2> nul
@$(REBAR) -r eunit $(EUNIT_OPTS)

setup-eunit: export BUILDDIR = $(shell pwd)
setup-eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config")
setup-eunit:
@set ERL_AFLAGS="-config rel/files/eunit.config" && set BUILDDIR = $(shell echo %cd%) && $(REBAR) setup_eunit 2> nul
@$(REBAR) setup_eunit 2> nul

just-eunit: export BUILDDIR = $(shell pwd)
just-eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config")
just-eunit:
@set ERL_AFLAGS="-config rel/files/eunit.config" && set BUILDDIR = $(shell echo %cd%) && $(REBAR) -r eunit $(EUNIT_OPTS)
@$(REBAR) -r eunit $(EUNIT_OPTS)


.PHONY: elixir
Expand Down
3 changes: 3 additions & 0 deletions make.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

make.exe -f Makefile.win %*
11 changes: 9 additions & 2 deletions src/mango/test/15-execution-stats-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


import mango
import os
import unittest

class ExecutionStatsTests(mango.UserDocsTests):
Expand All @@ -23,7 +24,10 @@ def test_simple_json_index(self):
self.assertEqual(resp["execution_stats"]["total_docs_examined"], 3)
self.assertEqual(resp["execution_stats"]["total_quorum_docs_examined"], 0)
self.assertEqual(resp["execution_stats"]["results_returned"], 3)
self.assertGreater(resp["execution_stats"]["execution_time_ms"], 0)
# See https://github.com/apache/couchdb/issues/1732
# Erlang os:timestamp() only has ms accuracy on Windows!
if os.name != 'nt':
self.assertGreater(resp["execution_stats"]["execution_time_ms"], 0)

def test_no_execution_stats(self):
resp = self.db.find({"age": {"$lt": 35}}, return_raw=True, executionStats=False)
Expand All @@ -36,7 +40,10 @@ def test_quorum_json_index(self):
self.assertEqual(resp["execution_stats"]["total_docs_examined"], 0)
self.assertEqual(resp["execution_stats"]["total_quorum_docs_examined"], 3)
self.assertEqual(resp["execution_stats"]["results_returned"], 3)
self.assertGreater(resp["execution_stats"]["execution_time_ms"], 0)
# See https://github.com/apache/couchdb/issues/1732
# Erlang os:timestamp() only has ms accuracy on Windows!
if os.name != 'nt':
self.assertGreater(resp["execution_stats"]["execution_time_ms"], 0)

def test_results_returned_limit(self):
resp = self.db.find({"age": {"$lt": 35}}, limit=2, return_raw=True, executionStats=True)
Expand Down
2 changes: 1 addition & 1 deletion test/elixir/lib/couch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Couch do
"""

def process_url(url) do
"http://localhost:15984" <> url
"http://127.0.0.1:15984" <> url
end

def process_request_headers(headers, options) do
Expand Down
2 changes: 1 addition & 1 deletion test/elixir/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Foo.Mixfile do
[
# {:dep_from_hexpm, "~> 0.3.0"},
{:httpotion, "~> 3.0"},
{:jiffy, "~> 0.14.11"}
{:jiffy, "~> 0.15.2"}
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
]
end
Expand Down
6 changes: 3 additions & 3 deletions test/elixir/mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{
"httpotion": {:hex, :httpotion, "3.0.3", "17096ea1a7c0b2df74509e9c15a82b670d66fc4d66e6ef584189f63a9759428d", [:mix], [{:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: false]}], "hexpm"},
"ibrowse": {:hex, :ibrowse, "4.4.0", "2d923325efe0d2cb09b9c6a047b2835a5eda69d8a47ed6ff8bc03628b764e991", [:rebar3], [], "hexpm"},
"jiffy": {:hex, :jiffy, "0.14.11", "919a87d491c5a6b5e3bbc27fafedc3a0761ca0b4c405394f121f582fd4e3f0e5", [:rebar3], [], "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"},
"jiffy": {:hex, :jiffy, "0.15.2", "de266c390111fd4ea28b9302f0bc3d7472468f3b8e0aceabfbefa26d08cd73b7", [:rebar3], [], "hexpm"},
}
2 changes: 2 additions & 0 deletions test/elixir/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
cd "$(dirname "$0")"
mix local.hex --force
mix local.rebar --force
mix deps.get
mix test --trace
2 changes: 2 additions & 0 deletions test/elixir/run.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@ECHO OFF

cd %~dp0
call mix local.hex --force
call mix local.rebar --force
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change, and the one to test/elixir/run, will be necessary to make the Elixir tests work in a CI environment - otherwise an interactive prompt is raised to first install hex, then to install rebar.

call mix deps.get
call mix test --trace
14 changes: 7 additions & 7 deletions test/elixir/test/replication_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ defmodule ReplicationTest do
@admin_account "adm:pass"
@db_pairs_prefixes [
{"local-to-local", "", ""},
{"remote-to-local", "http://localhost:15984/", ""},
{"local-to-remote", "", "http://localhost:15984/"},
{"remote-to-remote", "http://localhost:15984/", "http://localhost:15984/"}
{"remote-to-local", "http://127.0.0.1:15984/", ""},
{"local-to-remote", "", "http://127.0.0.1:15984/"},
{"remote-to-remote", "http://127.0.0.1:15984/", "http://127.0.0.1:15984/"}
]

# This should probably go into `make elixir` like what
Expand All @@ -31,7 +31,7 @@ defmodule ReplicationTest do

test "source database not found with host" do
name = random_db_name()
url = "http://localhost:15984/" <> name <> "_src"
url = "http://127.0.0.1:15984/" <> name <> "_src"
check_not_found(url, name <> "_tgt")
end

Expand All @@ -53,7 +53,7 @@ defmodule ReplicationTest do
doc = %{"_id" => "doc1"}
[doc] = save_docs(src_db_name, [doc])

result = replicate(src_db_name, "http://localhost:15984/" <> tgt_db_name)
result = replicate(src_db_name, "http://127.0.0.1:15984/" <> tgt_db_name)
assert result["ok"]
assert is_list(result["history"])
history = Enum.at(result["history"], 0)
Expand All @@ -73,7 +73,7 @@ defmodule ReplicationTest do
})
[doc] = save_docs(src_db_name, [doc])

result = replicate(src_db_name, "http://localhost:15984/" <> tgt_db_name)
result = replicate(src_db_name, "http://127.0.0.1:15984/" <> tgt_db_name)

assert result["ok"]
assert is_list(result["history"])
Expand Down Expand Up @@ -157,7 +157,7 @@ defmodule ReplicationTest do

save_docs(src_db_name, make_docs(1..6))

repl_src = "http://localhost:15984/" <> src_db_name
repl_src = "http://127.0.0.1:15984/" <> src_db_name
repl_body = %{"continuous" => true}
result = replicate(repl_src, tgt_db_name, body: repl_body)

Expand Down