Commit caa3c3a9 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia

[OPENBUS-2304] (Lua) Permitir fazer chamadas dentro de cadeias (join)...

[OPENBUS-2304] (Lua) Permitir fazer chamadas dentro de cadeias (join) recebidas com um login diferente, mas da mesma entidade
- Criação de teste (no estilo 'interop') que exercita o cenário mais usual do problema (i.e. join após um relogin).

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/lua/branches/02_00_00@142174 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 414060e6
local log = require "openbus.util.logger"
local openbus = require "openbus"
require "openbus.test.util"
-- setup the ORB
local orb = openbus.initORB()
-- load interface definition
orb:loadidlfile("idl/hello.idl")
local iface = orb.types:lookup("tecgraf::openbus::interop::simple::Hello")
-- customize test configuration for this case
settestcfg(iface, ...)
-- get bus context manager
local OpenBusContext = orb.OpenBusContext
-- connect to the bus
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
-- login to the bus
conn:loginByPassword(user, password)
-- define service properties
properties[#properties+1] =
{name="reloggedjoin.role",value="proxy"}
-- find the offered service
log:TEST("retrieve hello service")
local OfferRegistry = OpenBusContext:getOfferRegistry()
for _, offer in ipairs(findoffers(OfferRegistry, properties)) do
local entity = getprop(offer.properties, "openbus.offer.entity")
log:TEST("found service of ",entity,"!")
local hello = offer.service_ref:getFacetByName(iface.name):__narrow(iface)
local result = hello:sayHello()
assert(result == "Hello "..user.."!", result)
log:TEST("test successful for service of ",entity)
end
-- logout from the bus
conn:logout()
local table = require "loop.table"
local log = require "openbus.util.logger"
local openbus = require "openbus"
local ComponentContext = require "scs.core.ComponentContext"
require "openbus.test.util"
-- setup and start the ORB
local orb = openbus.initORB()
openbus.newThread(orb.run, orb)
-- load interface definition
orb:loadidlfile("idl/hello.idl")
local iface = orb.types:lookup("tecgraf::openbus::interop::simple::Hello")
-- customize test configuration for this case
settestcfg(iface, ...)
-- read login private key
local key = assert(openbus.readKeyFile(syskey))
-- get bus context manager
local OpenBusContext = orb.OpenBusContext
-- create service implementation
local hello = {}
function hello:sayHello()
local conn = OpenBusContext:getCurrentConnection()
log:TEST("relogging entity ",system)
conn:logout()
conn:loginByCertificate(system, key)
local chain = OpenBusContext:getCallerChain()
local entity = chain.caller.entity
log:TEST("got call from ",entity)
OpenBusContext:joinChain(chain)
-- define service properties
local searchprops = table.copy(properties)
searchprops[#searchprops+1] =
{name="reloggedjoin.role",value="server"}
-- find the offered service
log:TEST("retrieve hello service")
local OfferRegistry = OpenBusContext:getOfferRegistry()
for _, offer in ipairs(findoffers(OfferRegistry, searchprops)) do
local entity = getprop(offer.properties, "openbus.offer.entity")
log:TEST("found service of ",entity,"!")
local hello = offer.service_ref:getFacetByName(iface.name):__narrow(iface)
return hello:sayHello()
end
return "no service found!"
end
-- create service SCS component
local component = ComponentContext(orb, {
name = "Hello",
major_version = 1,
minor_version = 0,
patch_version = 0,
platform_spec = "Lua",
})
component:addFacet(iface.name, iface.repID, hello)
-- connect to the bus
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
-- login to the bus
conn:loginByCertificate(system, key)
-- define service properties
local servprops = table.copy(properties)
servprops[#servprops+1] =
{name="reloggedjoin.role",value="proxy"}
-- offer service
local OfferRegistry = OpenBusContext:getOfferRegistry()
OfferRegistry:registerService(component.IComponent, servprops)
log:TEST("hello service proxy ready!")
local table = require "loop.table"
local log = require "openbus.util.logger"
local openbus = require "openbus"
local ComponentContext = require "scs.core.ComponentContext"
require "openbus.test.util"
-- setup and start the ORB
local orb = openbus.initORB()
openbus.newThread(orb.run, orb)
-- load interface definition
orb:loadidlfile("idl/hello.idl")
local iface = orb.types:lookup("tecgraf::openbus::interop::simple::Hello")
-- customize test configuration for this case
settestcfg(iface, ...)
-- get bus context manager
local OpenBusContext = orb.OpenBusContext
-- create service implementation
local hello = {}
function hello:sayHello()
local chain = OpenBusContext:getCallerChain()
local entity = chain.caller.entity
local originators = chain.originators
if #originators > 0 then
entity = originators[1].entity
end
log:TEST("got call from ",entity)
return "Hello "..entity.."!"
end
-- create service SCS component
local component = ComponentContext(orb, {
name = "Hello",
major_version = 1,
minor_version = 0,
patch_version = 0,
platform_spec = "Lua",
})
component:addFacet(iface.name, iface.repID, hello)
-- connect to the bus
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
-- login to the bus
conn:loginByCertificate(system, assert(openbus.readKeyFile(syskey)))
-- define service properties
local servprops = table.copy(properties)
servprops[#servprops+1] =
{name="reloggedjoin.role",value="server"}
-- offer service
local OfferRegistry = OpenBusContext:getOfferRegistry()
OfferRegistry:registerService(component.IComponent, servprops)
log:TEST("hello service ready!")
......@@ -3,4 +3,5 @@
/bin/bash runtest.sh $1 simple server
/bin/bash runtest.sh $1 multiplexing server
/bin/bash runtest.sh $1 sharedauth server
/bin/bash runtest.sh $1 reloggedjoin server proxy
/bin/bash runtest.sh $1 delegation messenger broadcaster forwarder
......@@ -9,6 +9,7 @@ for case, services in pairs{
Simple = { "Hello" },
Multiplexing = { "Hello" },
SharedAuth = { "Hello" },
ReloggedJoin = { "Hello" },
Delegation = { "Messenger","Broadcaster","Forwarder" },
} do
for _, iface in ipairs(services) do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment