theLink 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - py - rb - jv - cc
Loading...
Searching...
No Matches
Example: Identification-Test

Documentation of the Test-Client-Server tool used for example.test.

INTRODUCTION

The Naming-Test-Tool tool is used to test the name-resolution-feature of rbmqmsgque.

To perform the test 2 tools are used, the testclient and the testserver.

testclient

This tool creates multiple parent and child client-context, all using a --postfix argument to identify unique.

testserver This tool listen on the service GTCX and return the unique identification pattern of the server-context in duty.

All context created, 8x client and 8x server, are connected using the rbmqmsgque protocoll and build together a flat structure.

The GOAL for this setup is:

CODE client

#+
#:   @file         NHI1/example/rb/testclient.rb
#:   @brief        testclient.rb - 26 Jun 2024 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      08a242faddae5101924d8fe811888e78892a82d9
#:   @date         Wed Jun 26 14:26:21 2024 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:
require "rbmqmsgque"
include RbMsgque::MqMsgque
## setup the clients
server = File.join(File.dirname($0), "testserver.rb")
## create object
c0 = MqContextC.new
c00 = MqContextC.new
c01 = MqContextC.new
c000 = MqContextC.new
c1 = MqContextC.new
c10 = MqContextC.new
c100 = MqContextC.new
c101 = MqContextC.new
## setup object link
c0.LinkCreate(            "c0",    "--postfix", "0",      "--prefix", "c", "--debug", ENV['TS_DEBUG'], 
                                                          "@", ENV['RUBY'], server, "--prefix", "s")
c00.LinkCreateChild(c0,   "c00",   "--postfix", "00"  )
c01.LinkCreateChild(c0,	  "c01",   "--postfix", "01"  )
c000.LinkCreateChild(c00, "c000",  "--postfix", "000" )
c1.LinkCreate(            "c1",    "--postfix", "1",      "--prefix", "c", *ARGV)
c10.LinkCreateChild(c1,   "c10",   "--postfix", "10"  )
c100.LinkCreateChild(c10, "c100",  "--postfix", "100" )
c101.LinkCreateChild(c10, "c101",  "--postfix", "101" )
## my helper
def Get(ctx)
  ret = ""
  ctx.SendSTART()
  ctx.SendEND_AND_WAIT("GTCX")
  ret += ctx.ConfigGetName()
  ret += "+"
  ret += ctx.ReadSTR()
  ret += ctx.ReadSTR()
  ret += ctx.ReadSTR()
  ret += ctx.ReadSTR()
  ret += ctx.ReadSTR()
  ret += ctx.ReadSTR()
  return ret
end
## do the tests
$stdout.puts(Get(c0))
$stdout.puts(Get(c00))
$stdout.puts(Get(c01))
$stdout.puts(Get(c000))
$stdout.puts(Get(c1))
$stdout.puts(Get(c10))
$stdout.puts(Get(c100))
$stdout.puts(Get(c101))
$stdout.flush
## do the cleanup
c1.LinkDelete()
c0.Exit()

CODE server

#+
#:   @file         NHI1/example/rb/testserver.rb
#:   @brief        testserver.rb - 26 Jun 2024 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      08a242faddae5101924d8fe811888e78892a82d9
#:   @date         Wed Jun 26 14:26:21 2024 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:

require "rbmqmsgque"
include RbMsgque::MqMsgque

class TestServer < MqContextC
  def initialize()
    ConfigSetServerSetup(method(:ServerSetup))
    super()
  end
  def GTCX
    SendSTART()
    SendI32(LinkGetCtxId())
    SendSTR("+")
    if (LinkIsParent())
      SendI32(-1)
    else
      SendI32(LinkGetParent().LinkGetCtxId())
    end
    SendSTR("+")
    SendSTR(ConfigGetName())
    SendSTR(":")
    SendRETURN()
  end
  def ServerSetup
    ServiceCreate("GTCX",method(:GTCX))
  end
end

srv = MqFactoryC.Add(TestServer).New()
begin
  srv.LinkCreate(ARGV)
  srv.ProcessEvent(MqWaitOnEventE::FOREVER)
rescue Exception => ex
  srv.ErrorCatch(ex)
ensure
  srv.Exit()
end