Stats Methods

Introduction

The tester stats methods provide a library of functions which are typically used in test scripts for the IN Tester for the purpose of validating statistics counters.

Tester helper methods are accessed via the “n2.n2svcd.tester.stats” module:

    local stats = require "n2.n2svcd.tester.stats"

.delta [Synchronous]

The delta method uses the n2svcd.management_summary method to fetch an application’s current statistics values.

When called repeatedly, it computes a delta of the statistics counter changes since the previous call.

This allows a test script to validate that the application’s statistics counters have changed by the expected amount as a result of the intermediate test actions.

The parameters for this method are:

Parameter Type Description
app_name String [Required] The name of the application whose management summary we are requesting.
This must be a real application name, it cannot be a virtual (load-share/failover) app name.
previous Table The checkpoint object from the previous invocation.

The delta method returns two result values.

Parameter Type Description
deltas Table A table keyed by statistics names returned from the management_summary.
The value for each entry is the delta from the previous checkpoint.
current Table The checkpoint object which should be passed into the next invocation of this method.

Example:

  local delta, checkpoint

  delta, checkpoint = stats.delta ('Logic', checkpoint)

    [intermediate test processing goes here]

  delta, checkpoint = stats.delta ('Logic', checkpoint)
  n2svcd.match_integer ('instance.start', delta['instance.start'], 3)
  n2svcd.match_integer ('instance.shutdown', delta['instance.shutdown'], 3)
  n2svcd.match_integer ('messages.rcvd', delta['messages.rcvd'], 1)
  n2svcd.match_integer ('messages.sent', delta['messages.sent'], 2)