Lewis John McGibbney created NUTCH-3245:
-------------------------------------------
Summary: Add a counter-name convention test and a crawl counter
test
Key: NUTCH-3245
URL: https://issues.apache.org/jira/browse/NUTCH-3245
Project: Nutch
Issue Type: Sub-task
Reporter: Lewis John McGibbney
The metrics report's suggestion 13 asks for tests that counters increment, that
names stay consistent, and that counters do not leak.
What already exists:
* \{{TestErrorTracker}} and \{{TestLatencyTracker}} exercise the utility
classes.
* \{{TestFetcherReducer}} and \{{TestParseSegment}} assert latency percentiles
through \{{LatencyTestUtil}}. They drive the reducer with a \{{LATENCY_KEY}}
record. They do not run a crawl, and they do not assert
\{{urls_injected_total}} or \{{bytes_downloaded_total}}.
Nothing checks the naming rules on \{{NutchMetrics}}, and nothing fails when a
crawl job stops incrementing a counter.
h2. Proposal
Add two tests under \{{src/test/org/apache/nutch/metrics/}}.
* A convention test that reflects over the \{{public static final String}}
fields of \{{NutchMetrics}}. Group values start with \{{nutch_}} and are
snake_case. Counter values are snake_case. Accumulating counts end in
\{{_total}}. The fields that are not counters are \{{FETCHER_LATENCY}},
\{{PARSER_LATENCY}}, \{{INDEXER_LATENCY}}, and \{{LATENCY_KEY}}. Do not require
a \{{_ms}} suffix on \{{NutchMetrics}} fields. Those suffixes are constants on
\{{LatencyTracker}} (\{{SUFFIX_COUNT_TOTAL}}, \{{SUFFIX_SUM_MS}},
\{{SUFFIX_P50_MS}}, \{{SUFFIX_P95_MS}}, \{{SUFFIX_P99_MS}}) and should be
asserted there.
* A job-level test that runs a small crawl fixture through inject, generate,
fetch, parse, and index, then asserts \{{nutch_injector}} /
\{{urls_injected_total}}, the \{{nutch_generator}} counters the fixture
produces, \{{nutch_fetcher}} / \{{bytes_downloaded_total}}, and
\{{nutch_fetcher}} / \{{fetch_latency_count_total}} are non-zero. Read the
group names from \{{NutchMetrics}} constants. Do not re-assert the percentile
ranges already covered by \{{TestFetcherReducer}} and \{{TestParseSegment}}.
* An invariant test for the checks that issue 1 moved out of the runtime,
because they cannot fail inside a single tracker. It asserts two things. First,
that \{{errors_total}} equals the sum of the \{{errors_*_total}} category
counters for a mixed set of \{{ErrorTracker}} categories, with the dynamic
hostdb bucket counter excluded from that sum. Second, that the merged digest
weight from \{{LatencyTracker.merge}} equals the merged \{{count_total}}, since
the digest and the count come from the same samples through different channels.
h2. Acceptance
* A constant that breaks the naming rules fails the convention test, and the
message names the field.
* \{{FETCHER_LATENCY}}, \{{PARSER_LATENCY}}, \{{INDEXER_LATENCY}}, and
\{{LATENCY_KEY}} pass.
* The job-level test fails when one of the asserted counters is no longer
incremented.
* The invariant test passes for a mixed set of \{{ErrorTracker}} categories and
a merged latency digest, and fails if either invariant is broken.
* Both tests run under \{{ant test-core}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)