theLink 10.0
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 atlmqmsgque.

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 atlmqmsgque protocoll and build together a flat structure.

The GOAL for this setup is:

CODE client

#!/usr/bin/env atlsh
#+
#:   @file         NHI1/example/atl/testclient.atl
#:   @brief        tag: nhi1-release-250425
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permission to copy,
#:                 please contact AUTHOR for additional information
#:

#package require lib_debug
package require lib_85

package require atlmqmsgque
namespace import MqContextC::*

set server  [file join [file dirname [info script]] testserver.atl]

proc Get {ctx} {
  SendSTART $ctx
  SendEND_AND_WAIT $ctx "GTCX"
  append RET [ConfigGetName $ctx]
  append RET "+"
  append RET [ReadSTR $ctx]
  append RET [ReadSTR $ctx]
  append RET [ReadSTR $ctx]
  append RET [ReadSTR $ctx]
  append RET [ReadSTR $ctx]
  append RET [ReadSTR $ctx]
  return $RET
}

# create object
set LIST [list c0 c00 c01 c000 c1 c10 c100 c101]
foreach F $LIST {
  set FH($F) [MqContextC::Create]
}

## create link
LinkCreate $FH(c0)		    "--postfix" "0"   "--prefix" "c" "--debug" $env(TS_DEBUG) "@" \
                                                              $env(TCLSH) $server "--prefix" "s"
LinkCreateChild $FH(c00)  $FH(c0)   "--postfix" "00"  
LinkCreateChild $FH(c01)  $FH(c0)   "--postfix" "01"  
LinkCreateChild $FH(c000) $FH(c00)  "--postfix" "000" 

LinkCreate $FH(c1)	      	    "--postfix" "1"   "--prefix" "c"  {*}$argv
LinkCreateChild $FH(c10)  $FH(c1)   "--postfix" "10"  
LinkCreateChild $FH(c100) $FH(c10)  "--postfix" "100" 
LinkCreateChild $FH(c101) $FH(c10)  "--postfix" "101" 

## do the tests
foreach F $LIST {
  puts [Get $FH($F)]
}

## cleanup
foreach n [lreverse $LIST] {
  myooX::DestroyN $FH($n)
}

CODE server

#!/usr/bin/env atlsh
#+
#:   @file         NHI1/example/atl/testserver.atl
#:   @brief        tag: nhi1-release-250425
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permission to copy,
#:                 please contact AUTHOR for additional information
#:

package require lib_85

package require atlmqmsgque
namespace import MqContextC::*

proc GTCX {ctx} {
  SendSTART $ctx
  SendI32 $ctx [LinkGetCtxId $ctx]
  SendSTR $ctx "+"
  if {[LinkIsParent $ctx]} {
    SendI32 $ctx -1
  } else {
    SendI32 $ctx [LinkGetCtxId [LinkGetParent $ctx]]
  }
  SendSTR $ctx "+"
  SendSTR $ctx [ConfigGetName $ctx]
  SendSTR $ctx ":"
  SendRETURN $ctx
}
proc ServerSetup {ctx} {
  ServiceCreate $ctx "GTCX" GTCX
}
MqMsgque::Main {
  myooX::Create2N ::MqContextC ::srv
  ConfigSetServerSetup ::srv ServerSetup
  try {
    LinkCreate ::srv {*}$argv
    ProcessEvent ::srv MQ_WAIT_FOREVER
  } on error {} {
    ErrorCatch ::srv
  } finally {
    Exit ::srv
  }
}