Skip to content

Commit

Permalink
fix for review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Akayeshmantha committed Mar 23, 2020
1 parent 0b5ee35 commit 8f77ab6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
20 changes: 0 additions & 20 deletions .travis/osx_openresty_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@ before_install() {
sudo cpanm --notest Test::Nginx >build.log 2>&1 || (cat build.log && exit 1)
export_or_prefix
luarocks install --lua-dir=${OPENRESTY_PREFIX}/luajit luacov-coveralls --local --tree=deps

# spin up kafka cluster for tests (1 zookeper and 1 kafka instance)
export ZK_VER=3.5.7
export SCALA_VER=2.11
export KAFKA_VER=2.4.0

if [ ! -f download-cache/kafka_$SCALA_VER-$KAFKA_VER.tgz ]; then wget -P download-cache http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/$KAFKA_VER/kafka_$SCALA_VER-$KAFKA_VER.tgz;fi
if [ ! -f download-cache/apache-zookeeper-$ZK_VER-bin.tar.gz ]; then wget -P download-cache https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-$ZK_VER/apache-zookeeper-$ZK_VER-bin.tar.gz;fi

sudo tar -xzf download-cache/apache-zookeeper-$ZK_VER-bin.tar.gz -C /usr/local/
sudo tar -xzf download-cache/kafka_$SCALA_VER-$KAFKA_VER.tgz -C /usr/local/
sudo mv /usr/local/kafka_$SCALA_VER-$KAFKA_VER /usr/local/kafka
sudo mv /usr/local/apache-zookeeper-$ZK_VER-bin /usr/local/zookeeper
sudo cp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg
sudo sed -i '' '$a\
host\.name=127.0.0.1' /usr/local/kafka/config/server.properties
sudo /usr/local/zookeeper/bin/zkServer.sh start
sudo /usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
sleep 1
/usr/local/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 2 --topic test2
}

do_install() {
Expand Down
2 changes: 0 additions & 2 deletions lua/apisix/plugins/kafka-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ local function log(premature, conf, log_message)
local prod, err = producer:new(broker_list,broker_config)
if err then
core.log.error("failed to identify the broker specified", err)

return
end

local ok, err = prod:send(conf.kafka_topic, conf.key, log_message)
if not ok then
core.log.error("failed to send data to Kafka topic", err)
end

end

function _M.log(conf)
Expand Down
11 changes: 11 additions & 0 deletions t/plugin/kafka-logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ no_root_location();
run_tests;

__DATA__

=== TEST 1: sanity
--- config
location /t {
Expand All @@ -47,6 +48,8 @@ done
--- no_error_log
[error]



=== TEST 2: missing broker list
--- config
location /t {
Expand All @@ -67,6 +70,8 @@ done
--- no_error_log
[error]



=== TEST 3: wrong type of string
--- config
location /t {
Expand Down Expand Up @@ -94,6 +99,8 @@ done
--- no_error_log
[error]



=== TEST 4: add plugin
--- config
location /t {
Expand Down Expand Up @@ -159,6 +166,8 @@ passed
--- no_error_log
[error]



=== TEST 5: access
--- request
GET /hello
Expand All @@ -168,6 +177,8 @@ hello world
[error]
--- wait: 0.2



=== TEST 6: error log
--- config
location /t {
Expand Down

0 comments on commit 8f77ab6

Please sign in to comment.