Skip to content

Commit 5e9c6e5

Browse files
authored
Merge pull request #97 from puzza007/remove-docker-for-tests
Use cowboy instead of docker for unix socket test
2 parents cc466a8 + 712ee4d commit 5e9c6e5

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ group: edge
44

55
language: erlang
66

7-
services:
8-
- docker
9-
107
install:
118
- ORIG_DIR=$PWD
129
- wget https://github.com/erlang/rebar3/releases/download/3.10.0/rebar3 && chmod 755 rebar3
@@ -29,7 +26,7 @@ before_install:
2926

3027
cache:
3128
directories:
32-
- $HOME/.cache/rebar3/
29+
- $HOME/.cache/rebar3/
3330

3431
addons:
3532
apt:

rebar.config

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
[{deps,
1616
[{jsx, "2.9.0"},
1717
{meck, "0.8.10"},
18-
{cowboy, "2.4.0"},
18+
{cowboy, "2.6.3"},
19+
{ephemeral, "2.0.4"},
1920
{http_proxy, ".*", {git, "https://github.com/puzza007/http_proxy.git", {branch, "rebar3"}}}
2021
]}]
2122
}]

test/katipo_SUITE.erl

+15-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ init_per_suite(Config) ->
1919
end_per_suite(_Config) ->
2020
ok = application:stop(katipo).
2121

22+
init_per_group(http, Config) ->
23+
application:ensure_all_started(cowboy),
24+
Filename = tempfile:name("katipo_test_"),
25+
Dispatch = cowboy_router:compile([{'_', [{"/unix", get_handler, []}]}]),
26+
{ok, _} = cowboy:start_clear(unix_socket, [{ip, {local, Filename}},
27+
{port, 0}], #{env => #{dispatch => Dispatch}}),
28+
[{unix_socket_file, Filename} | Config];
2229
init_per_group(session, Config) ->
2330
application:ensure_all_started(katipo),
2431
Config;
@@ -43,6 +50,10 @@ init_per_group(proxy, Config) ->
4350
init_per_group(_, Config) ->
4451
Config.
4552

53+
end_per_group(http, Config) ->
54+
Filename = ?config(unix_socket_file, Config),
55+
_ = file:delete(Filename),
56+
Config;
4657
end_per_group(pool, Config) ->
4758
application:stop(meck),
4859
Config;
@@ -425,10 +436,11 @@ interface_unknown(_) ->
425436
{error, #{code := interface_failed}} =
426437
katipo:get(?POOL, <<"https://httpbin.org/get">>, #{interface => <<"cannot_be_an_interface">>}).
427438

428-
unix_socket_path(_) ->
429-
case katipo:get(?POOL, <<"http://localhost/images/json">>, #{unix_socket_path => <<"/var/run/docker.sock">>}) of
439+
unix_socket_path(Config) ->
440+
Filename = list_to_binary(?config(unix_socket_file, Config)),
441+
case katipo:get(?POOL, <<"http://localhost/unix">>, #{unix_socket_path => Filename}) of
430442
{ok, #{status := 200, headers := Headers}} ->
431-
<<"Docker/",_/binary>> = proplists:get_value(<<"Server">>, Headers);
443+
<<"Cowboy">> = proplists:get_value(<<"server">>, Headers);
432444
{error, #{code := bad_opts}} ->
433445
ct:pal("unix_socket_path not supported by installed version of curl"),
434446
ok

0 commit comments

Comments
 (0)