0

I am working on one end to end testing scenario where I need a user record perf map use a key which is a reference to meta_table id within the same use case.

While user data is stored in NoSQL database, meta_table is stored in RDBMS and uses autogenerated id, so each time I run only a test workflow meta_table for the same use cases is having completely new id generated.

Here is my data setup workflow:

pipeline:
  db1:
    register:
      action: dsunit:register
      datastore: db1
      config:
        driverName: mysql
        descriptor: '[username]:[password]@tcp(127.0.0.1:3306)/[dbname]?parseTime=true'
        credentials: $mysqlCredentials
        parameters:
          dbname: db1
    prepare:
      sequence:
        datastore: db1
        action: dsunit.sequence
        tables:
        - meta_table
        post:
        - seq = $Sequences
      data:
        action: nop
        init:
        - db1key = data.db1.setup
        - db1Setup = $AsTableRecords($db1key)
      setup:
        datastore: db1
        action: dsunit:prepare
        data: $db1Setup
  db2:
    register:
      action: dsunit:register
      datastore: db2
      config:
        driverName: aerospike
        descriptor: tcp([host]:3000)/[namespace]
        parameters:
          namespace: test
          host: 127.0.0.1
          port: 3000
    prepare:
      data:
        action: nop
        init:
        - db2key = data.db2.setup
        - db2Setup = $AsTableRecords($db2key)
      setup:
        datastore: db2
        action: dsunit:prepare
        data: $db2Setup

And there are my data files:

@db1_setup.json

[
  {
    "Table": "meta_table",
    "Value": {
      "id": "$seq.meta_table",
      "name": "Name 1",
      "type_id": 1
    },
    "PostIncrement": [
      "seq.meta_table"
    ],
    "Key": "${tagId}_meta_table"
  }
]



@db2_setup.json

[
  {
    "Table": "user",
    "Value": {
      "id": "$userID",
      "email": "user@abc.com",
      "perf": {
        "??meta_table.id here??": "$timestamp"
      }
    },
    "AutoGenerate": {
      "userID": "uuid.next"
    },
    "Key": "${tagId}_user"
  }
]

I am looking for a valid expression to replace:

"??meta_table.id here??" 

to expand to meta_table.id,

I have tried the following, but none worked:

  • $meta_table.id
  • ${meta_table.id}
terry.zhao
  • 29
  • 1
  • 2

1 Answers1

0

You want to use

${dsunit.${tagId}_meta_table[0].id}

dsunit since that is the root

{tagId}_meta_table since that is the Key to your table

[0] since the table can have multiple rows