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

Bump Openresty to 1.15.8.1 version #1049

Merged
merged 6 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ executors:
environment:
S2I_VERSION: "1.1.12-2a783420"
DOCKER_COMPOSE_VERSION: "1.16.1"
OPENRESTY_VERSION: "1.13.6.2-2"
OPENRESTY_VERSION: "1.15.8.1-0"

openresty:
working_directory: /opt/app-root/apicast
docker:
- image: quay.io/3scale/s2i-openresty-centos7:1.13.6.2-2
- image: quay.io/3scale/s2i-openresty-centos7:1.15.8.1-0
- image: redis:3.2.8-alpine
environment:
TEST_NGINX_BINARY: openresty
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `APICAST_PATH_ROUTING_ONLY` variable that allows to perform path-based routing without falling back to the default host-based routing [PR #1035](https://github.com/3scale/APIcast/pull/1035), [THREESCALE-1150](https://issues.jboss.org/browse/THREESCALE-1150)
- Added the option to manage access based on method on Keycloak Policy. [THREESCALE-2236](https://issues.jboss.org/browse/THREESCALE-2236) [PR #1039](https://github.com/3scale/APIcast/pull/1039)
- The Rate Limit policy now supports conditions defined with the "matches" operation. [PR #1051](https://github.com/3scale/APIcast/pull/1051), [THREESCALE-2590](https://issues.jboss.org/browse/THREESCALE-2590)
- Upgrade OpenResty to 1.15.8.1 release.[PR #1049](https://github.com/3scale/APIcast/pull/1049), [THREESCALE-2200](https://issues.jboss.org/browse/THREESCALE-2200)

### Fixed

Expand Down
5 changes: 5 additions & 0 deletions bin/busted.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-- Clean warning on openresty 1.15.8.1, where some global variables are set
-- using ngx.timer that triggers an invalid warning message.
-- Code related: https://github.com/openresty/lua-nginx-module/blob/61e4d0aac8974b8fad1b5b93d0d3d694d257d328/src/ngx_http_lua_util.c#L795-L839
getmetatable(_G).__newindex = nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why this is needed 🙏


if ngx ~= nil then
ngx.exit = function()end
end
Expand Down
6 changes: 5 additions & 1 deletion gateway/src/apicast/executor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ local function build_context(executor)
end

local function shared_build_context(executor)
local ctx = ngx.ctx or {}
local ok, ctx = pcall(function() return ngx.ctx end)
if not ok then
ctx = {}
end

local context = ctx.context

if not context then
Expand Down
3 changes: 1 addition & 2 deletions spec/resty/openssl/bio_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ describe('OpenSSL BIO', function()

it('requires non empty string', function()
local bio = _M.new()

assert.has_error(function () bio:write('') end, 'expected value, got nil')
assert.same(bio:write(""), 0)
end)
end)

Expand Down
7 changes: 5 additions & 2 deletions t/management.t
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,11 @@ init_by_lua_block {
GET /dns/cache
--- response_headers
Content-Type: application/json; charset=utf-8
--- response_body
{"127.0.0.1.xip.io":{"value":{"1":{"address":"127.0.0.1","class":1,"ttl":199,"name":"127.0.0.1.xip.io","section":1,"type":1},"ttl":199,"name":"127.0.0.1.xip.io"},"expires_in":199}}
--- expected_response_body_like_multiple eval
[[
qr/"name":"127.0.0.1.xip.io"/,
qr/\{"127.0.0.1.xip.io":\{"value":{"1":{"address":"127.0.0.1","class":1,"ttl":199/,
]]
--- no_error_log
[error]

Expand Down
36 changes: 36 additions & 0 deletions t/policies.pl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,39 @@
};

add_response_body_check($expect_json);

# This response body helper function check is like a response_body_like but it
# can be used with multiple values for a single request.
#
# An usage example can be like this:
# --- expected_response_body_like_multiple eval
# [
# qr/.*/,
# qr/[0-9]*/,
# [
# qr/^a.*/,
# qr/Z$/
# ]]
#
# Where the third request will validate that starts with a and finish with Z.
add_response_body_check(sub {
my ($block, $body, $req_idx, $repeated_req_idx, $dry_run) = @_;

if (!$block->expected_response_body_like_multiple) {
return "";
}

my @asserts = @{$block->{expected_response_body_like_multiple}};
my $assertValues = ${asserts}[0][$req_idx];
if (ref(${assertValues}) eq 'ARRAY') {
foreach my $regexp(@{$assertValues}){
if (!($body =~ m/$regexp/)) {
fail(sprintf("Regular expression: '%s' does not match with the body: \n %s",$regexp, $body));
}
}
}else{
if (!($body =~ m/$assertValues/)) {
fail(sprintf("Regular expression: '%s' does not match with the body: \n %s",$assertValues, $body));
}
}
});
41 changes: 1 addition & 40 deletions t/prometheus-metrics.t
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
use lib 't';
use Test::APIcast::Blackbox 'no_plan';

# This response body helper function check is like a response_body_like but it
# can be used with multiple values for a single request.

# The reason to make this helper function is to make sure that multiple regexp
# can be used with the same body to validate that everything is working as
# expected.
#
# An usage example can be like this:
# --- expected_response_body_like_multiple eval
# [
# qr/.*/,
# qr/[0-9]*/,
# [
# qr/^a.*/,
# qr/Z$/
# ]]
#
# Where the third request will validate that starts with a and finish with Z.
add_response_body_check(sub {
my ($block, $body, $req_idx, $repeated_req_idx, $dry_run) = @_;

if (!$block->expected_response_body_like_multiple) {
return "";
}

my @asserts = @{$block->{expected_response_body_like_multiple}};
my $assertValues = ${asserts}[0][$req_idx];
if (ref(${assertValues}) eq 'ARRAY') {
foreach my $regexp(@{$assertValues}){
if (!($body =~ m/$regexp/)) {
fail(sprintf("Regular expression: '%s' does not match with the body: \n %s",$regexp, $body));
}
}
}else{
if (!($body =~ m/$assertValues/)) {
fail(sprintf("Regular expression: '%s' does not match with the body: \n %s",$assertValues, $body));
}
}
});

require("t/policies.pl");
# The output varies between requests, so run only once
repeat_each(1);

Expand Down