You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by we...@apache.org on 2020/03/08 08:00:27 UTC
[incubator-apisix] branch master updated: test case: adding test
case for extending buffer timer (#1222)
This is an automated email from the ASF dual-hosted git repository.
wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 1c3fd30 test case: adding test case for extending buffer timer (#1222)
1c3fd30 is described below
commit 1c3fd309f147c4cb5cf2e95d729627035fa9b40d
Author: Nirojan Selvanathan <ss...@gmail.com>
AuthorDate: Sun Mar 8 09:00:19 2020 +0100
test case: adding test case for extending buffer timer (#1222)
---
t/utils/batch-processor.t | 52 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/t/utils/batch-processor.t b/t/utils/batch-processor.t
index 22b8c01..4b3a569 100644
--- a/t/utils/batch-processor.t
+++ b/t/utils/batch-processor.t
@@ -32,7 +32,6 @@ __DATA__
local config = {
max_retry_count = 2,
batch_max_size = 1,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -71,7 +70,6 @@ failed
local config = {
max_retry_count = 2,
batch_max_size = 1,
- process_delay = 0,
retry_delay = 0,
}
@@ -103,7 +101,6 @@ Batch Processor[log buffer] successfully processed the entries
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
inactive_timeout = 1
}
@@ -139,7 +136,6 @@ Batch Processor[log buffer] successfully processed the entries
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -179,7 +175,6 @@ Batch Processor[log buffer] successfully processed the entries
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -219,7 +214,6 @@ Batch Processor[log buffer] successfully processed the entries
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -259,7 +253,6 @@ Batch Processor[log buffer] exceeded the max_retry_count
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -301,7 +294,6 @@ batch[2] sent
local config = {
max_retry_count = 0,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -339,7 +331,6 @@ Batch Processor[log buffer] exceeded the max_retry_count
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
buffer_duration = 60,
inactive_timeout = 1,
@@ -377,7 +368,6 @@ Batch Processor[log buffer] successfully processed the entries
local config = {
max_retry_count = 2,
batch_max_size = 2,
- process_delay = 0,
retry_delay = 0,
}
local func_to_send = function(elements)
@@ -407,3 +397,45 @@ BatchProcessor[log buffer] activating flush due to no activity
[{"msg":"1"},{"msg":"2"}]
[{"msg":"3"},{"msg":"4"}]
--- wait: 0.5
+
+
+
+=== TEST 11: extend timer
+--- config
+ location /t {
+ content_by_lua_block {
+ local Batch = require("apisix.utils.batch-processor")
+ local core = require("apisix.core")
+ local config = {
+ max_retry_count = 1,
+ batch_max_size = 3,
+ retry_delay = 0,
+ inactive_timeout = 1
+ }
+ local func_to_send = function(elements)
+ core.log.info(core.json.encode(elements))
+ return true
+ end
+ local log_buffer, err = Batch:new(func_to_send, config)
+
+ if not log_buffer then
+ ngx.say(err)
+ end
+
+ log_buffer:push({msg='1'})
+ ngx.sleep(0.3)
+ log_buffer:push({msg='2'})
+ log_buffer:push({msg='3'})
+ log_buffer:push({msg='4'})
+ ngx.say("done")
+ }
+ }
+--- request
+GET /t
+--- response_body
+done
+--- no_error_log
+BatchProcessor[log buffer] activating flush due to no activity
+--- error_log
+BatchProcessor[log buffer] extending buffer timer
+--- wait: 3