Skip to content

Commit

Permalink
Faster Travis tests, and some fixes
Browse files Browse the repository at this point in the history
Former-commit-id: 688e638cf420f86e39a574eb0c98a36ceb41e500
  • Loading branch information
subnetmarco committed May 27, 2015
1 parent cd59b34 commit 9655d44
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 242 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ branches:
- master

before_install:
- bash .travis/setup_lua.sh
- bash .travis/setup_openresty.sh
- export PATH=$PATH:/usr/local/openresty/nginx/sbin
- bash .travis/setup_kong.sh
- bash .travis/setup_cassandra.sh
- bash .travis/setup_dnsmasq.sh

install:
- sudo make install
- sudo make dev

script:
- "busted --coverage spec/"
- "busted -o spec/busted-print.lua --coverage spec/ spec/"
- "luacheck kong"

after_success: "luacov-coveralls -i kong"
1 change: 1 addition & 0 deletions .travis/kong-0.3.0travis.precise_all.deb.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bce95eeda6a509f6f92d9e7537089a17006ee45b
15 changes: 0 additions & 15 deletions .travis/platform.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/setup_dnsmasq.sh

This file was deleted.

14 changes: 14 additions & 0 deletions .travis/setup_kong.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

source ./versions.sh

sudo apt-get update

# Installing dependencies required to build development rocks
sudo apt-get install wget curl tar make gcc unzip git liblua5.1-0-dev

# Installing dependencies required for Kong
sudo apt-get install sudo netcat lua5.1 openssl libpcre3 dnsmasq

# Installing Kong and its dependencies
sudo dpkg -i ./.travis/kong-0.3.0travis.precise_all.deb
101 changes: 0 additions & 101 deletions .travis/setup_lua.sh

This file was deleted.

62 changes: 0 additions & 62 deletions .travis/setup_openresty.sh

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TESTING_CONF = kong_TEST.yml
DEVELOPMENT_CONF = kong_DEVELOPMENT.yml
DEV_ROCKS=busted luacov luacov-coveralls luacheck
DEV_ROCKS=busted luacov luacov-coveralls luacheck ansicolors

.PHONY: install dev clean start seed drop lint test coverage test-all

Expand Down
20 changes: 0 additions & 20 deletions distributions/build-package-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,6 @@ tar xzf ssl-cert-by-lua.tar.gz
NGX_LUA=`ls | grep ngx_lua-*`
rm -rf $NGX_LUA
mv lua-nginx-module-ssl-cert-by-lua $NGX_LUA
# Install ssl.lua
cd $NGX_LUA/lua
echo '
package = "ngxssl"
version = "0.1-1"
source = {
url = "git://github.com/openresty/lua-nginx-module",
branch = "ssl-cert-by-lua"
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = {
["ngx.ssl"] = "ngx/ssl.lua"
}
}
' > ngxssl-0.1-1.rockspec
$OUT/usr/local/bin/luarocks make ngxssl-0.1-1.rockspec
# Configure and install
cd $TMP/ngx_openresty-$OPENRESTY_VERSION
./configure --with-pcre-jit --with-ipv6 --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module ${OPENRESTY_CONFIGURE}
Expand Down
9 changes: 0 additions & 9 deletions kong/cli/utils/signal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,6 @@ function _M.send_signal(args_config, signal)
end
end

local nginx_pid
if IO.file_exists(kong_config.pid_file) then
nginx_pid = stringy.strip(IO.read_file(kong_config.pid_file))
end

-- Build nginx signal command
local cmd = string.format("KONG_CONF=%s %s -p %s -c %s -g 'pid %s;' %s",
kong_config_path,
Expand Down Expand Up @@ -315,10 +310,6 @@ function _M.send_signal(args_config, signal)
stop_dnsmasq(kong_config) -- If the start failed, then stop dnsmasq
end

if success and (signal == STOP or signal == QUIT) and nginx_pid then
IO.os_execute("while kill -0 "..nginx_pid.." >/dev/null 2>&1; do sleep 0.1; done")
end

return success
end

Expand Down
7 changes: 2 additions & 5 deletions kong/cli/utils/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ local constants = require "kong.constants"
local Object = require "classic"
local lpath = require "luarocks.path"
local IO = require "kong.tools.io"
local socket = require "socket"

--
-- Colors
Expand Down Expand Up @@ -152,10 +151,8 @@ end
-- @param `port` The port to check
-- @return `open` True if open, false otherwise
local function is_port_open(port)
local tcp = socket.tcp()
local ok = tcp:connect("127.0.0.1", port)
tcp:close()
return ok
local _, code = IO.os_execute("nc -w 3 127.0.0.1 "..tostring(port).." <<< \"\"")
return code == 0
end

return {
Expand Down
21 changes: 21 additions & 0 deletions spec/busted-print.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local ansicolors = require 'ansicolors'

return function(options)
local handler = require 'busted.outputHandlers.utfTerminal'(options)

handler.fileStart = function(file)
io.write('\n' .. ansicolors('%{cyan}' .. file.name) .. ':')
end

handler.testStart = function(element, parent, status, debug)
io.write('\n ' .. handler.getFullName(element) .. ' ... ')
io.flush()
end

local busted = require 'busted'

busted.subscribe({ 'file', 'start' }, handler.fileStart)
busted.subscribe({ 'test', 'start' }, handler.testStart)

return handler
end
2 changes: 1 addition & 1 deletion spec/integration/admin_api/admin_api_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local ENDPOINTS = {
}
},
update_fields = { enabled = false },
error_message = '{"name":"name is required","api_id":"api_id is required","value":"value is required"}\n'
error_message = '{"api_id":"api_id is required","name":"name is required"}\n'
}
}

Expand Down
9 changes: 3 additions & 6 deletions spec/plugins/logging_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ uuid.seed()
local STUB_GET_URL = spec_helper.STUB_GET_URL
local TEST_CONF = "kong_TEST.yml"

local TCP_PORT = 7777
local UDP_PORT = 7778
local HTTP_PORT = 7779
local TCP_PORT = 20777
local UDP_PORT = 20778
local HTTP_PORT = 20779

describe("Logging Plugins", function()

Expand Down Expand Up @@ -79,11 +79,8 @@ describe("Logging Plugins", function()
end)

it("should log to HTTP", function()
pending()
local thread = spec_helper.start_http_server(HTTP_PORT) -- Starting the mock TCP server

--os.execute("sleep 0.5")

-- Making the request
local _, status = http_client.get(STUB_GET_URL, nil, { host = "http_logging.com" })
assert.are.equal(200, status)
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ end
-- Add the default env to our spec_helper
_M.add_env(_M.TEST_CONF_FILE)

return _M
return _M
2 changes: 1 addition & 1 deletion spec/unit/schemas_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ describe("Schemas", function()
local valid, err = validate(obj, schema)
assert.truthy(err)
assert.False(valid)
--assert.are.same("hello", obj.value.some_property)
assert.are.same("value is required", err.value)
end)

end)
Expand Down
12 changes: 1 addition & 11 deletions versions.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
# Travis only
CASSANDRA_VERSION=2.1.5

# Travis and package builder
LUAROCKS_VERSION=2.2.2
OPENRESTY_VERSION=1.7.10.2rc0

# Package builder only
LUA_VERSION=5.1.4
PCRE_VERSION=8.36
KONG_VERSION=0.2.0-2
OPENSSL_VERSION=1.0.2a
CASSANDRA_VERSION=2.1.5

0 comments on commit 9655d44

Please sign in to comment.