Skip to content

th2-net/th2-act-template-j

Repository files navigation

th2 act template (5.4.1)

Overview

Act is a passive th2 component with parameterized functions which is implemented as part of the test logic. Script or other components can call these functions via gRPC. Act can interact with codec, hands, check1s, other acts to execute its tasks. Information about the progress of the task is published to the estore th2 component via MQ pin. This th2 component type allows frequently used script logic into it and then share it between all th2 components.

This project is implemented gRPC API described in the th2-grpc-act-template

Most of them consists of the next steps:

  1. Gets a gRPC request with parameters.
  2. If check1Enabled option is true, requests checkpoint from check1 via gRPC pin otherwise generates empty checkpoint
  3. Sends the passed business message to Codec via mq pin
  4. Waits the specific business message from Codec during specified timeout
  5. Returns responded business message with checkpoint (checkpoint is empty when check1Enabled option is false) picture

Sending raw messages

It is also possible to send raw messages ( containing metadata and having payload in original format ) directly to conn components without waiting while message will be encoded by codec and then sent to conn component. For that you need to:

  1. Send rpc request using SendRawMessageRequest and sendRawMessage rpc that is defined in th2-grpc-act-template
  2. Transport group with RawMessage will be published to pins with send_raw attribute.

Placing http messages

It is also possible to place messages for th2-conn-http-client. This rpc call sends request with act event id and waits response with the same event id. After receiving response, act check statusCode field to calculate rpc response status. For that you need to send rpc request using PlaceHttpRequest and placeHttpRequest rpc that is defined in th2-grpc-act-template placeHttpRequest rpc supports the scenarios:

  1. place header only:
    • requirements: PlaceHttpRequest.httpHeader.messageType must have Request value.
    • schema: act =[parsed]=> conn-http
    • pin attributes: [transport-group, send_http]
  2. place parsed body only:
    • schema: act =[parsed]=> codec-* =[raw]=> conn-http
    • pin attributes: [transport-group, send]
  3. place raw body only:
    • schema: act =[raw]=> conn-http
    • pin attributes: [transport-group, send_http]
  4. place header and parsed body:
    • requirements:
      • PlaceHttpRequest.httpHeader.messageType must have Request value.
      • PlaceHttpRequest.httpHeader.metadata.protocol must not be blank to avoid codec-* encoding).
    • schema: act =[parsed,parsed]=> codec-* =[parsed,raw]=> conn-http
    • pin attributes: [transport-group, send]
  5. place header and raw body:
    • requirements: PlaceHttpRequest.httpHeader.messageType must have Request value.
    • schema: act =[parsed,raw]=> conn-http
    • pin attributes: [transport-group, send_http]

Custom resources for infra-mgr

apiVersion: th2.exactpro.com/v2
kind: Th2Box
metadata:
  name: act
spec:
  type: th2-act
  customConfig:
    response-timeout: 10000
    check1-enabled: true
  pins:
    mq:
      publishers:
        - name: to_codec_fix
          attributes: [publish, transport-group, send]
          filters:
            - metadata:
                - fieldName: "session_alias"
                  expectedValue: "*-fix-*"
                  operation: WILDCARD
        - name: to_codec_json
          attributes: [publish, transport-group, send]
          filters:
            - metadata:
                - fieldName: "session_alias"
                  expectedValue: "*-http-*"
                  operation: WILDCARD

        - name: to_conn_client_fix
          attributes: [publish, transport-group, send_raw]
          filters:
            - metadata:
                - fieldName: "session_alias"
                  expectedValue: "client-fix-*"
                  operation: WILDCARD
        - name: to_conn_client_http
          attributes: [publish, transport-group, send_http]
          filters:
            - metadata:
                - fieldName: "session_alias"
                  expectedValue: "client-http-*"
                  operation: WILDCARD
      subscribers:
        - name: from_codec
          attributes: [subscribe, transport-group, oe]
          linkTo:
            - box: codec-fix
              pin: out_realtime_decode
    grpc:
      client:
        - name: to_check1 # this pin optional when spec.customConfig.check1Enabled: false
          serviceClass: com.exactpro.th2.check1.grpc.Check1Service
          linkTo:
            - box: check1
              pin: server
      server:
        - name: server
          serviceClasses:
            - com.exactpro.th2.act.grpc.ActService

Descriptor gradle plugin

Also we recommend to apply th2-box-descriptor-generator plugin. It allows generating a th2 descriptor. CI should publish the project's docker image with the descriptor content as the value of the protobuf-description-base64 label. Such descriptors can be used to interact with a box-raised gRPC server.

Release Notes

5.4.1

  • Produce multi-platform docker image
  • Updated:
    • th2 gradle plugin: 0.3.10 (bom: 4.14.2)
    • kotlin: 2.2.21

5.4.0

5.3.0

  • Provided check1-enabled option
  • Migrate to th2 gradle plugin 0.3.9 (th2-bom: 4.14.1)
  • Updated:
    • kotlin: 2.2.10
    • common: 5.16.1-dev
    • common-utils: 2.4.0-dev
    • grpc-act-template: 4.3.1
    • grpc-check1: 4.5.1

5.2.0

  • multiSendMessage method implemented

5.1.1

  • Use pins with send pin attribute for parsed messages sends.

5.1.0

  • Added RPC to send raw messages.
  • Updated grpc-act-template to 4.2.0

5.0.0

  • Migrated to th2 transport protocol
  • Updated bom to 4.5.0
  • Updated kotlin to 1.8.22
  • Updated common to 5.4.0
  • Updated grpc-act-template to 4.1.0
  • Updated grpc-check1 to 4.3.0
  • Added common-utils 2.2.0

4.0.1

  • 3.9.0 merged

4.0.0

  • Update kotlin.jvm version from 1.3.72 to 1.5.30
  • Migration to books/pages cradle 4.0.0
    • Update th2-common version from 3.26.4 to 4.0.0
    • Update th2-grpc-act-template version from 3.4.0 to 4.0.0
    • Update th2-grpc-check1 version from 3.4.2 to 4.0.0

3.9.0

  • th2-common to 3.44.1
  • th2-bom to 4.2.0
  • th2-grpc-check to 3.8.0
  • grpc-check1 updated to 3.8.0
  • updated gradle to 7.6

3.8.0

  • Update th2-grpc-act-template version from 3.9.0 to 3.10.0
  • Implement placeOrderCancelRequest and placeOrderCancelReplaceRequest methods

3.7.0

  • Update th2-common version from 3.26.4 to 3.44.0
  • Update th2-grpc-act-template version from 3.4.0 to 3.9.0
  • Update th2-grpc-check1 version from 3.4.2 to 3.6.0
  • Update kotlin version from 1.3.72 to 1.6.21

3.5.0

  • Update th2-common version from 3.16.5 to 3.26.4
  • Update th2-grpc-act-template version from 3.2.0 to 3.4.0
  • Update th2-grpc-check1 version from 3.2.0 to 3.4.2

3.4.1

  • Make gRPC response objects containing logs about the errors that happened in gRPC methods
  • Fixed configuration for gRPC server.
    • Added the property workers, which changes the count of gRPC server's threads

3.3.1

  • add creation of error event in case the sendMessage call did not success

3.3.0

  • migration to Sonatype

3.2.1

  • removed gRPC event loop handling
  • fixed dictionary reading

3.2.0

  • reads dictionaries from the /var/th2/config/dictionary folder.
  • uses mq_router, grpc_router, cradle_manager optional JSON configs from the /var/th2/config folder
  • tries to load log4j.properties files from sources in order: '/var/th2/config', '/home/etc', configured path via cmd, default configuration
  • update Cradle version. Introduce async API for storing events

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors