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

Clustering, cache invalidation and event bus #729

Closed
wants to merge 10 commits into from
Closed
2 changes: 1 addition & 1 deletion .ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

CMD="busted -v -o gtest --exclude-tags=ci"
CMD="busted -v -o gtest --exclude-tags=ci --repeat=3"

if [ "$TEST_SUITE" == "unit" ]; then
CMD="$CMD --coverage spec/unit && luacov-coveralls -i kong"
Expand Down
22 changes: 22 additions & 0 deletions .ci/setup_dnsmasq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

if [ "$TEST_SUITE" == "unit" ]; then
echo "Exiting, no integration tests"
exit
fi

mkdir -p $DNSMASQ_DIR

if [ ! "$(ls -A $DNSMASQ_DIR)" ]; then
pushd $DNSMASQ_DIR
wget http://www.thekelleys.org.uk/dnsmasq/dnsmasq-${DNSMASQ_VERSION}.tar.gz
tar xzf dnsmasq-${DNSMASQ_VERSION}.tar.gz

pushd dnsmasq-${DNSMASQ_VERSION}
make install DESTDIR=$DNSMASQ_DIR
popd

popd
fi
28 changes: 14 additions & 14 deletions .ci/setup_lua.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ source .ci/platform.sh
# Lua/LuaJIT
############

if [ "$LUA" == "luajit" ]; then
if [ "$LUA_VERSION" == "luajit" ]; then
LUAJIT="yes"
LUA="luajit-2.0"
elif [ "$LUA" == "luajit-2.0" ]; then
LUA_VERSION="luajit-2.0"
elif [ "$LUA_VERSION" == "luajit-2.0" ]; then
LUAJIT="yes"
elif [ "$LUA" == "luajit-2.1" ]; then
elif [ "$LUA_VERSION" == "luajit-2.1" ]; then
LUAJIT="yes"
fi

Expand All @@ -33,32 +33,32 @@ if [ "$LUAJIT" == "yes" ]; then
git clone https://github.com/luajit/luajit $LUAJIT_DIR
pushd $LUAJIT_DIR

if [ "$LUA" == "luajit-2.0" ]; then
if [ "$LUA_VERSION" == "luajit-2.0" ]; then
git checkout v2.0.4
elif [ "$LUA" == "luajit-2.1" ]; then
elif [ "$LUA_VERSION" == "luajit-2.1" ]; then
git checkout v2.1
fi

make
make install PREFIX=$LUAJIT_DIR
popd

if [ "$LUA" == "luajit-2.1" ]; then
if [ "$LUA_VERSION" == "luajit-2.1" ]; then
ln -sf $LUAJIT_DIR/bin/luajit-2.1.0-beta1 $LUAJIT_DIR/bin/luajit
fi

ln -sf $LUAJIT_DIR/bin/luajit $LUAJIT_DIR/bin/lua
fi

LUA_INCLUDE="$LUAJIT_DIR/include/$LUA"
LUA_INCLUDE="$LUAJIT_DIR/include/$LUA_VERSION"
else
if [ "$LUA" == "lua5.1" ]; then
if [ "$LUA_VERSION" == "lua5.1" ]; then
curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
pushd lua-5.1.5
elif [ "$LUA" == "lua5.2" ]; then
elif [ "$LUA_VERSION" == "lua5.2" ]; then
curl http://www.lua.org/ftp/lua-5.2.3.tar.gz | tar xz
pushd lua-5.2.3
elif [ "$LUA" == "lua5.3" ]; then
elif [ "$LUA_VERSION" == "lua5.3" ]; then
curl http://www.lua.org/ftp/lua-5.3.0.tar.gz | tar xz
pushd lua-5.3.0
fi
Expand All @@ -84,11 +84,11 @@ git checkout v$LUAROCKS_VERSION

if [ "$LUAJIT" == "yes" ]; then
LUA_DIR=$LUAJIT_DIR
elif [ "$LUA" == "lua5.1" ]; then
elif [ "$LUA_VERSION" == "lua5.1" ]; then
CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --lua-version=5.1"
elif [ "$LUA" == "lua5.2" ]; then
elif [ "$LUA_VERSION" == "lua5.2" ]; then
CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --lua-version=5.2"
elif [ "$LUA" == "lua5.3" ]; then
elif [ "$LUA_VERSION" == "lua5.3" ]; then
CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --lua-version=5.3"
fi

Expand Down
17 changes: 17 additions & 0 deletions .ci/setup_serf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

if [ "$TEST_SUITE" == "unit" ]; then
echo "Exiting, no integration tests"
exit
fi

mkdir -p $SERF_DIR

if [ ! "$(ls -A $SERF_DIR)" ]; then
pushd $SERF_DIR
wget https://releases.hashicorp.com/serf/${SERF_VERSION}/serf_${SERF_VERSION}_linux_amd64.zip
unzip serf_${SERF_VERSION}_linux_amd64.zip
popd
fi
4 changes: 2 additions & 2 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
redefined = false
unused_args = false
globals = {"ngx", "dao", "app", "configuration", "process_id"}
globals = {"ngx", "dao", "app", "configuration", "events"}

files["kong/"] = {
std = "luajit"
Expand All @@ -20,5 +20,5 @@ files["kong/vendor/resty_http.lua"] = {
}

files["spec/"] = {
globals = {"describe", "it", "before_each", "setup", "after_each", "teardown", "stub", "mock", "spy", "finally", "pending"}
globals = {"describe", "it", "before_each", "setup", "after_each", "teardown", "stub", "mock", "spy", "finally", "pending", "build"}
}
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ addons:
- build-essential
env:
global:
- LUA=luajit-2.1
- CASSANDRA_VERSION=2.1.9
- LUA_VERSION=luajit-2.1
- CASSANDRA_VERSION=2.2.4
- LUAROCKS_VERSION=2.2.2
- OPENSSL_VERSION=1.0.2e
- OPENRESTY_VERSION=1.9.3.1
- SERF_VERSION=0.7.0
- DNSMASQ_VERSION=2.75
- LUAJIT_DIR=$HOME/luajit
- LUAROCKS_DIR=$HOME/luarocks
- OPENRESTY_DIR=$HOME/openresty
- SERF_DIR=$HOME/serf
- DNSMASQ_DIR=$HOME/dnsmasq
- CASSANDRA_HOSTS=127.0.0.1
matrix:
- TEST_SUITE=unit
Expand All @@ -28,7 +32,9 @@ before_install:
- bash .ci/setup_lua.sh
- bash .ci/setup_openresty.sh
- bash .ci/setup_cassandra.sh
- export PATH="$LUAJIT_DIR/bin:$LUAROCKS_DIR/bin:$OPENRESTY_DIR/nginx/sbin:$PATH"
- bash .ci/setup_serf.sh
- bash .ci/setup_dnsmasq.sh
- export PATH="$LUAJIT_DIR/bin:$LUAROCKS_DIR/bin:$OPENRESTY_DIR/nginx/sbin:$SERF_DIR:$DNSMASQ_DIR/usr/local/sbin:$PATH"
- export LUA_PATH="./?.lua;$LUAROCKS_DIR/share/lua/5.1/?.lua;$LUAROCKS_DIR/share/lua/5.1/?/init.lua;$LUAROCKS_DIR/lib/lua/5.1/?.lua;$LUA_PATH"
- export LUA_CPATH="./?.so;$LUAROCKS_DIR/lib/lua/5.1/?.so;$LUA_CPATH"
install:
Expand All @@ -38,7 +44,6 @@ install:
- luarocks install luacheck
- luarocks make kong-*.rockspec
- "kong config -c kong.yml -e TEST"
- 'sed -i "2 i\dns_resolver: server" kong_TEST.yml'
script:
- make lint
- .ci/run_tests.sh
Expand All @@ -49,4 +54,6 @@ cache:
- $LUAJIT_DIR
- $LUAROCKS_DIR
- $OPENRESTY_DIR
- $HOME/.ccm/repository
- $SERF_DIR
- $DNSMASQ_DIR
- $HOME/.ccm/repository
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ coverage:
@rm -f luacov.*
@busted --coverage spec/
@luacov -c spec/.luacov
@tail -n 1 luacov.report.out | awk '{ print $$3 }'
@tail -n 1 luacov.report.out | awk '{ print $$3 }'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Support, Demo, Training, API Certifications and Consulting available at https://
## License

```
Copyright 2015 Mashape, Inc
Copyright 2016 Mashape, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
28 changes: 15 additions & 13 deletions bin/kong
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@
-- This script is not parsed by lapp due to limitations of the said framework as it
-- is currently implemented.

local cutils = require "kong.cli.utils"
local infos = cutils.get_kong_infos()
local luarocks = require "kong.cli.utils.luarocks"
local infos = luarocks.get_kong_infos()
local commands = {
db = "kong.cli.db",
stop = "kong.cli.stop",
quit = "kong.cli.quit",
start = "kong.cli.start",
reload = "kong.cli.reload",
config = "kong.cli.config",
restart = "kong.cli.restart",
version = "kong.cli.version",
["--version"] = "kong.cli.version",
migrations = "kong.cli.migrations"
db = "kong.cli.cmds.db",
stop = "kong.cli.cmds.stop",
quit = "kong.cli.cmds.quit",
start = "kong.cli.cmds.start",
reload = "kong.cli.cmds.reload",
config = "kong.cli.cmds.config",
restart = "kong.cli.cmds.restart",
version = "kong.cli.cmds.version",
status = "kong.cli.cmds.status",
migrations = "kong.cli.cmds.migrations",
cluster = "kong.cli.cmds.cluster",
["--version"] = "kong.cli.cmds.version"
}

local help_message = string.format([[
Usage: kong <command>

where <command> is one of:
start, restart, reload, stop, quit, version
start, restart, reload, stop, quit, cluster, status, migrations, version

kong --help print this message
kong <command> --help print the help message of a command
Expand Down
Loading