Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests covering ignored prefixes #102

Closed
DamianZaremba opened this issue Dec 15, 2019 · 1 comment
Closed

Add tests covering ignored prefixes #102

DamianZaremba opened this issue Dec 15, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@DamianZaremba
Copy link
Contributor

Describe what you would like to achieve
The tests should validate that an ignored (per the config) prefix is not having messages generated about it and thus is actually being ignored, rather than alerted upon.

Related issue: #100

Describe why the current solution (if any) is not satisfactory
Currently there are a number of tests that assert expected messages are generated from the relevant monitors.

It is possible to have additional tests, not existing in the expectedData, which are never 'seen' by the current test logic.

Provide an example
On current master (pre #100), add an example update for an ignored prefix to the misconfiguration data in connectorTest.js;

                        {
                            data: {
                                announcements: [{
                                    prefixes: ["2a0e:240::/32"],
                                    next_hop: "124.0.0.3"
                                }],
                                peer: "124.0.0.4",
                                path: [1, 2, 3, 4321, 5060, 3333]
                            },
                            type: "ris_message"
                        },
                        {
                            data: {
                                announcements: [{
                                    prefixes: ["2a0e:240::/32"],
                                    next_hop: "124.0.0.5"
                                }],
                                peer: "124.0.0.6",
                                path: [1, 2, 3, 4321, 5060, 3333]
                            },
                            type: "ris_message"
                        }

The test receives 2 messages (1 incorrect);

{
  id: '2914',
  origin: 'asn-monitor',
  earliest: 1576436988706,
  latest: 1576436988707,
  affected: 2914,
  message: 'AS2914 is announcing 2.2.2.3/22 but this prefix is not in the configured list of announced prefixes',
  data: [
    {
      extra: {},
      matchedRule: [Object],
      matchedMessage: [Object],
      timestamp: 1576436988706
    },
    {
      extra: {},
      matchedRule: [Object],
      matchedMessage: [Object],
      timestamp: 1576436988707
    },
    {
      extra: {},
      matchedRule: [Object],
      matchedMessage: [Object],
      timestamp: 1576436988707
    }
  ]
}
{
  id: '3333',
  origin: 'asn-monitor',
  earliest: 1576436988707,
  latest: 1576436988708,
  affected: 3333,
  message: 'AS3333 is announcing 2a0e:240::/32 but this prefix is not in the configured list of announced prefixes',
  data: [
    {
      extra: {},
      matchedRule: [Object],
      matchedMessage: [Object],
      timestamp: 1576436988707
    },
    {
      extra: {},
      matchedRule: [Object],
      matchedMessage: [Object],
      timestamp: 1576436988708
    }
  ]
}

And asserts 1 message;

  Alerting
    ✓ asn monitoring reporting (1013ms)

The second (incorrect) message should either be asserted to not exist (explicit ignore check), or the number of messages should match the length of the expected data (implicit, no additional messages check).

@DamianZaremba DamianZaremba added the enhancement New feature or request label Dec 15, 2019
@massimocandela
Copy link
Member

Hi Damian,

This is already in place.

The following line checks that the alert reported was expected

    expect(Object.keys(expectedData).includes(id)).to.equal(true);

In case of a wrongly reported alert (from an ignored prefix) this line would fail and so the entire test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants