Hello Stefan.petrea, I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/98524 to review the following change. Change subject: Add tests for Special:CentralAutoLogin requests ...................................................................... Add tests for Special:CentralAutoLogin requests Change-Id: I8b5e86b6150d2f7580b54d2c89905ccaf9d7c4f2 --- M tests/test.sh 1 file changed, 71 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/webstatscollector refs/changes/24/98524/1 diff --git a/tests/test.sh b/tests/test.sh index ec212cc..871061a 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -28,6 +28,66 @@ fi } +set_FILTERED_OUTPUT() { + local URL="$1" + + local LOG_LINE="CACHE_MACHINE" + LOG_LINE="$LOG_LINE SEQUENCE_NUMBER" + LOG_LINE="$LOG_LINE TIMESTAMP" + LOG_LINE="$LOG_LINE DURATION" + LOG_LINE="$LOG_LINE IP" + LOG_LINE="$LOG_LINE STATUS_CODE" + LOG_LINE="$LOG_LINE SIZE" + LOG_LINE="$LOG_LINE REQUEST_METHOD" + LOG_LINE="$LOG_LINE $URL" + LOG_LINE="$LOG_LINE HIERARCHY_STATUS_OR_PEER_IP" + LOG_LINE="$LOG_LINE MIME" + LOG_LINE="$LOG_LINE REFERRER" + LOG_LINE="$LOG_LINE X_FORWARDED_FOR USER_AGENT" + LOG_LINE="$LOG_LINE ACCEPT_LANGUAGE" + LOG_LINE="$LOG_LINE X_ANALYTICS" + + FILTERED_OUTPUT="$("$FILTER" <<<"$LOG_LINE" 2>&1 || echo "Filter bailed out")" +} + +assert_counted() { + local URL="$1" + local COUNTED_PROJECT="$2" + local COUNTED_PAGE="$3" + + shift 3 + + start_test "Assure to count $URL" + + local FILTERED_OUTPUT= + set_FILTERED_OUTPUT "$URL" "$@" + + if [ "$FILTERED_OUTPUT" = "$COUNTED_PROJECT 1 SIZE $COUNTED_PAGE" ] + then + mark_test_passed + else + mark_test_failed + fi +} + +assert_not_counted() { + local URL="$1" + + shift 1 + + start_test "Assure to not count $URL" + + local FILTERED_OUTPUT= + set_FILTERED_OUTPUT "$URL" "$@" + + if [ -z "$FILTERED_OUTPUT" ] + then + mark_test_passed + else + mark_test_failed + fi +} + start_test "Spaceless lines in filter" #---------------------------------------- TEST_SPACELESS_LINES=`cat entries-with-urls-with-spaces-2013-02-10.txt | "$FILTER" | perl -MData::Dumper -ne '@f=split(/\s/,$_,4); print if $f[3] =~ /\ /;' | wc -l` @@ -58,6 +118,17 @@ mark_test_failed fi +# Single log line tests -------------------------------------------------------- +assert_not_counted "http://upload.wikimedia.org/wikipedia/commons/f/f4/Ambox_content.png" +assert_not_counted "http://en.wikipedia.org/Not_Countworthy_(No_Slash_Wiki_Slash)" +assert_counted "http://en.wikipedia.org/wiki/Countworthy_on_enwiki" "en" "Countworthy_on_enwiki" +assert_counted "http://fr.wikipedia.org/wiki/Countworthy_on_frwiki" "fr" "Countworthy_on_frwiki" +assert_counted "http://en.wikipedia.org/wiki/Special:Some_Countworthy_Special_Page" "en" "Special:Some_Countworthy_Special_Page" +assert_not_counted "http://en.wikipedia.org/wiki/Special:CentralAutoLogin/createSession?gu_id=0&type=script&proto=http" +assert_not_counted "http://en.wikipedia.org/wiki/Special:CentralAutoLogin/checkLoggedIn?wikiid=commonswiki&proto=http&type=script" +assert_counted "http://en.wikipedia.org/wiki/Special:CentralAutoLogin" "en" "Special:CentralAutoLogin" +assert_counted "http://en.wikipedia.org/wiki/Special:CentralAutoLoginX/Countworthy" "en" "Special:CentralAutoLoginX/Countworthy" + # -- printing statistics ------------------------------------------------------- TESTS_FAILED=$((TESTS-TESTS_GOOD)) -- To view, visit https://gerrit.wikimedia.org/r/98524 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8b5e86b6150d2f7580b54d2c89905ccaf9d7c4f2 Gerrit-PatchSet: 1 Gerrit-Project: analytics/webstatscollector Gerrit-Branch: master Gerrit-Owner: QChris <christ...@quelltextlich.at> Gerrit-Reviewer: Stefan.petrea <ste...@garage-coding.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits