assert-logs

ETLUnit 3.9.6

 

Draft in Progress

This document is a draft and is under development.

 

Description

  • Perform assertions about one or more log files, or one or more log file excerpts.

Attributes

List of assert-logs() Attributes

 

 

 

 

 

 

 

 

 

 

 

 

- >> REF:

 @LogAssertion Common

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

expected-log:  - >>  TYPE:  Object (key-value pairs, comma separated)  

Either this, or 'expected-logs.' must be present
   

{

 

- >> REF:

 Assert-Log Common

 

 

 

 

 

 

 

 

 

 

assertion-mode:  - >>

POSSIBLE VALUES:

equals 

matches

contains-pattern

contains  << default 

log-name-pattern:  - >>  TYPE:  string

classifier:  - >>  TYPE:  string

failure-id:  - >>  TYPE:  string

expected-log-expression:  - >>  TYPE:  string

expected-log-file:  - >>  TYPE:  string 

 

}

expected-logs:  - >> TYPE:  Unique list of assert-log instances. 

Either this, or 'expected-log.' must be present
 

[

{

 

- >> REF:

 Assert-Log Common

 

 

 

 

 

 

 

 

 

 

assertion-mode:  - >>

POSSIBLE VALUES:

equals 

matches

contains-pattern

contains  << default 

log-name-pattern:  - >>  TYPE:  string

classifier:  - >>  TYPE:  string

failure-id:  - >>  TYPE:  string

expected-log-expression:  - >>  TYPE:  string

expected-log-file:  - >>  TYPE:  string 

 

},

{

...

}

]

assertion-mode:  - >>

Possible Values:

match-all

match-any

failure-id:  - >>  Type: string

log-defaults:  - >>  Type:  object (key-value pairs, comma-separated)

{

- >> REF:

 

 Assert-Log Common

 

 

 

 

 

 

 

 

 

 

assertion-mode:  - >>

POSSIBLE VALUES:

equals 

matches

contains-pattern

contains  << default 

log-name-pattern:  - >>  TYPE:  string

classifier:  - >>  TYPE:  string

failure-id:  - >>  TYPE:  string

expected-log-expression:  - >>  TYPE:  string

expected-log-file:  - >>  TYPE:  string 

 

}

Individual assert-logs() Attributes

expected-log:

  • An object.  An instance of assert-log common properties.

expected-logs:

assertion-mode:

failure-id:

  • Identifier to use as a Failure ID if the log assertion fails.

log-defaults:

  • An object.  It is an instance of assert-log common properties.
  • Any log-defaults property not specified for one of the expected logs will be applied as though it were specified.

Example

Location of expected-log-file Log Excerpt Files

 

assert-logs Code Example

  • In the example below, all the expected-log conditions must be true, or the test will fail. 
  • This is because match-all was specified for assertion-mode.
  • In this example, there is actually only one log file, the one specified in log-name-pattern.
  • The expected-log-file refers to a file that contains an excerpt of text, usually spanning several lines, that you expect to find in the log file.

 

Example of assert-logs

@Database(id: 'qpt_pet', modes: ['src','lkp'])

@Database(id: 'edw', modes: ['lkp'])

@Database(id: 'qpt-bmw-plant', modes: ['src','tgt'])

class load_item_price_fact

{

@BeforeTest

setVariables()

{

set(variable: 'parm-key', value: '1234567890');

set(variable: 'population_date', value: '20130630');

}

@Test

insertOnly()

{

stage(

source: 'LOAD_PPF_INSERT_BUCKET_DETAIL',

target-table: 'BUCKET_DETAIL',

target-schema: 'DBO',

connection-id: 'qpt_pet',

mode: 'src'

);

 

// ... [more stage operations]    

  

execute(

workflow: 'wkf_LOAD_ITEM_PRICE_FACT',

folder: 'EDW_QPT_TICKET',

run-instance-name:'1234567890',            

context:

{

pet-connection-src: 'informatica.connections.qpt_pet.src',

pet-connection-lkp: 'informatica.connections.qpt_pet.lkp',                

edw-connection-lkp: 'informatica.connections.edw.lkp',

bmw-plant-connection-src: 'informatica.connections.qpt-bmw-plant.tgt',

bmw-plant-connection-tgt: 'informatica.connections.qpt-bmw-plant.tgt'

}

);

 

assert-logs(

assertion-mode: 'match-all',

log-defaults: {

classifier: 'sessionLog',

log-name-pattern: 'log\\.1234567890\\.\\d{0,10}\\.\\d{14}$'

},

expected-logs:

[

{

expected-log-file: 'load_ipf_empty_ipf_src_loadsummary',

failure-id: 'FAIL_BAD_IPF_SRC'

},

{

expected-log-file: 'load_ipf_tld_src_loadsummary',

failure-id: 'FAIL_BAD_BLD_SRC'

},

{

expected-log-file: 'load_ipf_ins_tgt_loadsummary',

failure-id: 'FAIL_BAD_INS_TGT'

},

{

expected-log-file: 'load_ipf_empty_upd_tgt_loadsummary',

failure-id: 'FAIL_BAD_UPD_TGT'

},

{

expected-log-file: 'load_ipf_empty_del_tgt_loadsummary',

failure-id: 'FAIL_BAD_DEL_TGT'

},

{

expected-log-file: 'load_ipf_mapping_sample',

failure-id: 'FAIL_BAD_MAPPING'

}

]

);

}   

 }