Skip to content

Commit

Permalink
Merge pull request Kong#2060 from Mashape/fix/cassandra-settings
Browse files Browse the repository at this point in the history
fix(cassandra) correct some settings usage
  • Loading branch information
thibaultcha authored Feb 8, 2017
2 parents 94704b9 + d7eb347 commit 654b103
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kong/dao/db/cassandra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function _M.new(kong_config)
cluster_options.lb_policy = policy.new()
elseif kong_config.cassandra_lb_policy == "DCAwareRoundRobin" then
local policy = require("resty.cassandra.policies.lb.dc_rr")
cluster_options.lb_policy = policy.new(kong_config.cassandra_local_cluster)
cluster_options.lb_policy = policy.new(kong_config.cassandra_local_datacenter)
end

local cluster, err = Cluster.new(cluster_options)
Expand Down
2 changes: 1 addition & 1 deletion kong/dao/migrations/cassandra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ return {
elseif strategy == "NetworkTopologyStrategy" then
local dcs = {}
for _, dc_conf in ipairs(kong_config.cassandra_data_centers) do
local dc_name, dc_repl = string.match(dc_conf, "(%w+):(%d+)")
local dc_name, dc_repl = string.match(dc_conf, "([^:]+):(%d+)")
if dc_name and dc_repl then
table.insert(dcs, string.format("'%s': %s", dc_name, dc_repl))
else
Expand Down
27 changes: 27 additions & 0 deletions spec/02-integration/02-dao/05-use_cases_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,30 @@ helpers.for_each_dao(function(kong_config)
end)
end)
end)


describe("#cassandra", function()
describe("LB policy", function()
it("accepts DCAwareRoundRobin", function()
local helpers = require "spec.helpers"

local kong_config = helpers.test_conf

local database = kong_config.database
local cassandra_lb_policy = kong_config.cassandra_lb_policy
local cassandra_local_datacenter = kong_config.cassandra_local_datacenter

finally(function()
kong_config.database = database
kong_config.cassandra_lb_policy = cassandra_lb_policy
kong_config.cassandra_local_datacenter = cassandra_local_datacenter
end)

kong_config.database = "cassandra"
kong_config.cassandra_lb_policy = "DCAwareRoundRobin"
kong_config.cassandra_local_datacenter = "my-dc"

assert(Factory.new(kong_config))
end)
end)
end)

0 comments on commit 654b103

Please sign in to comment.