QChris has uploaded a new change for review.
https://gerrit.wikimedia.org/r/102292
Change subject: Make squid tests time-independent
......................................................................
Make squid tests time-independent
Several squid tests were hardcoded to rely on data for October
2012. However, SquidCountArchive.pl refuses to run for dates older
than a year. Hence, the tests did no longer pass. The tests are now time
independent by using the 1st, 2nd, and 3rd day of the previous month.
Change-Id: I4bf3d54c35665bd9ebec53ce9658141fa9a1983b
---
M squids/t/03-regression-wrong-domains-actually-ipv6.t
M squids/t/04-regression-countries-count-arithmetic.t
M squids/t/06-regression-mismatch-world-north-south-unknown.t
M squids/t/08-regression-tablets-discrepancy_for_config_editors.t
M squids/t/11-merge-australia-into-oceania.t
5 files changed, 175 insertions(+), 38 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/analytics/wikistats
refs/changes/92/102292/1
diff --git a/squids/t/03-regression-wrong-domains-actually-ipv6.t
b/squids/t/03-regression-wrong-domains-actually-ipv6.t
index 3f32e40..bef8d01 100644
--- a/squids/t/03-regression-wrong-domains-actually-ipv6.t
+++ b/squids/t/03-regression-wrong-domains-actually-ipv6.t
@@ -5,6 +5,7 @@
require 't/CommonConfig.pm';
use lib "testdata/regression-test-ipv6-wrong-external-domain/";
use SquidReportArchiveConfig;
+use POSIX 'strftime';
####################################################################################################
# Outline
@@ -35,8 +36,8 @@
# How are we going to test ?
#
# We will create two files from within this script
-# test/regression-test-ipv6-wrong-external-domain/sampled-1000.log-20121001.gz
-# test/regression-test-ipv6-wrong-external-domain/sampled-1000.log-20121002.gz
+#
test/regression-test-ipv6-wrong-external-domain/sampled-1000.log-${year}${month}01.gz
+#
test/regression-test-ipv6-wrong-external-domain/sampled-1000.log-${year}${month}02.gz
#
# These two files contain few entries which are present in this file.
# Then we'll run the SquidCountArchive.pl and SquidReportArchive.pl scripts
and we
@@ -48,15 +49,47 @@
#
####################################################################################################
+# We pick two days and simulate squid/varnish log output for
+# them. The days must not be older than one year, or otherwise
+# SquidCountArchive.pl will complain. So we resort to the 1st, 2nd,
+# and 3rd day of the previous month. That should always work.
+#
+# We're mostly interested in the 2nd day of the month, and filter for
+# that. The 1st and 3rd day of the month are just there to simulate
+# boundaries.
+my @date = gmtime(time);
+$date[4]--; # Set month to previous
+if ($date[4] < 0) {
+ # Month underrun. Make up by borrowing from year.
+ $date[4]+=12;
+ $date[5]--;
+}
-my $contents_2012_10_01 = 'ssl4 9060296 2012-09-30T07:03:32.607 0.001
240f:0:0:0:0:0:0:0 FAKE_CACHE_STATUS/200 3681 GET
http://upload.wikimedia.org/wikipedia/foundation/a/a7/CNtranslatebutton2.png
NONE/upload -
http://ja.wikipedia.org/wiki/%E5%8C%96%E5%AD%A6%E7%89%A9%E8%B3%AA%E5%AE%89%E5%85%A8%E6%80%A7%E3%83%87%E3%83%BC%E3%82%BF%E3%82%B7%E3%83%BC%E3%83%88
-
Mozilla/5.0%20(compatible;%20MSIE%209.0;%20Windows%20NT%206.1;%20WOW64;%20Trident/5.0)
XX
-sq82.wikimedia.org -1148359703 2012-09-30T07:03:34.215 0 0.0.0.0
TCP_IMS_HIT/304 347 GET
http://upload.wikimedia.org/wikipedia/foundation/a/a7/CNtranslatebutton2.png
NONE/- image/png
http://ja.wikipedia.org/wiki/%E5%A4%96%E5%B1%B1%E6%83%A0%E7%90%86
240f:13:98c7:1:54b6:1f15:1b8:aedf
Mozilla/5.0%20(compatible;%20MSIE%209.0;%20Windows%20NT%206.1;%20WOW64;%20Trident/5.0;%20Sleipnir/3.7.3)
XX
-ssl4 9167838 2012-10-01T00:22:55.449 0.011 240f:0:0:0:0:0:0:0
FAKE_CACHE_STATUS/200 3186 GET
http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Wikiquote-logo-en.svg/50px-Wikiquote-logo-en.svg.png
NONE/upload -
http://blog.daum.net/_blog/hdn/ArticleContentsView.do?blogid=0Chpo&articleno=16506447&looping=0&longOpen=
-
Mozilla/4.0%20(compatible;%20MSIE%207.0;%20Windows%20NT%206.0;%20Trident/5.0;%20SLCC1;%20.NET%20CLR%202.0.50727;%20Media%20Center%20PC%205.1;%20.NET%20CLR%203.5.30729;%20.NET%20CLR%203.0.30729;%20.NET4.0C;%20YTB730;%20BOIE9;JAJP)
XX
-ssl1 8687318 2012-10-01T00:23:59.955 0.000 240f:0:0:0:0:0:0:0
FAKE_CACHE_STATUS/400 0 - http://upload.wikimedia.org- NONE/- - - - - XX
+# First day of month
+$date[3]=1;
+my $day_1_ymd = strftime('%Y-%m-%d', @date);
+
+# Second day of month. This is the day we're interested in.
+$date[3]++;
+my $day_2_ym = strftime('%Y-%m', @date);
+my $day_2_ymd = strftime('%Y-%m-%d', @date);
+my $day_2_ymd_slash = strftime('%Y/%m/%d', @date);
+my $day_2_ymd_dense = strftime('%Y%m%d', @date);
+
+# Third day of month
+$date[3]++;
+my $day_3_ymd = strftime('%Y-%m-%d', @date);
+my $day_3_ymd_dense = strftime('%Y%m%d', @date);
+
+
+my $contents_day_2 = 'ssl4 9060296 ' . $day_1_ymd . 'T07:03:32.607 0.001
240f:0:0:0:0:0:0:0 FAKE_CACHE_STATUS/200 3681 GET
http://upload.wikimedia.org/wikipedia/foundation/a/a7/CNtranslatebutton2.png
NONE/upload -
http://ja.wikipedia.org/wiki/%E5%8C%96%E5%AD%A6%E7%89%A9%E8%B3%AA%E5%AE%89%E5%85%A8%E6%80%A7%E3%83%87%E3%83%BC%E3%82%BF%E3%82%B7%E3%83%BC%E3%83%88
-
Mozilla/5.0%20(compatible;%20MSIE%209.0;%20Windows%20NT%206.1;%20WOW64;%20Trident/5.0)
XX
+sq82.wikimedia.org -1148359703 ' . $day_1_ymd . 'T07:03:34.215 0 0.0.0.0
TCP_IMS_HIT/304 347 GET
http://upload.wikimedia.org/wikipedia/foundation/a/a7/CNtranslatebutton2.png
NONE/- image/png
http://ja.wikipedia.org/wiki/%E5%A4%96%E5%B1%B1%E6%83%A0%E7%90%86
240f:13:98c7:1:54b6:1f15:1b8:aedf
Mozilla/5.0%20(compatible;%20MSIE%209.0;%20Windows%20NT%206.1;%20WOW64;%20Trident/5.0;%20Sleipnir/3.7.3)
XX
+ssl4 9167838 ' . $day_2_ymd . 'T00:22:55.449 0.011 240f:0:0:0:0:0:0:0
FAKE_CACHE_STATUS/200 3186 GET
http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Wikiquote-logo-en.svg/50px-Wikiquote-logo-en.svg.png
NONE/upload -
http://blog.daum.net/_blog/hdn/ArticleContentsView.do?blogid=0Chpo&articleno=16506447&looping=0&longOpen=
-
Mozilla/4.0%20(compatible;%20MSIE%207.0;%20Windows%20NT%206.0;%20Trident/5.0;%20SLCC1;%20.NET%20CLR%202.0.50727;%20Media%20Center%20PC%205.1;%20.NET%20CLR%203.5.30729;%20.NET%20CLR%203.0.30729;%20.NET4.0C;%20YTB730;%20BOIE9;JAJP)
XX
+ssl1 8687318 ' . $day_2_ymd . 'T00:23:59.955 0.000 240f:0:0:0:0:0:0:0
FAKE_CACHE_STATUS/400 0 - http://upload.wikimedia.org- NONE/- - - - - XX
';
# The last line here ^^^ is the one causing the problems
-my $contents_2012_10_02 = 'ssl4 9094050 2012-10-02T00:00:00 0.002
240f:0:0:0:0:0:0:0 FAKE_CACHE_STATUS/200 13585 GET
http://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/San_Siro.jpg/220px-San_Siro.jpg
NONE/upload -
http://ja.wikipedia.org/wiki/%E3%82%A4%E3%83%B3%E3%83%86%E3%83%AB%E3%83%8A%E3%83%84%E3%82%A3%E3%82%AA%E3%83%8A%E3%83%BC%E3%83%AC%E3%83%BB%E3%83%9F%E3%83%A9%E3%83%8E
-
Mozilla/5.0%20(compatible;%20MSIE%209.0;%20Windows%20NT%206.1;%20Trident/5.0)
XX';
+my $contents_day_3 = 'ssl4 9094050 ' . $day_3_ymd . 'T00:00:00 0.002
240f:0:0:0:0:0:0:0 FAKE_CACHE_STATUS/200 13585 GET
http://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/San_Siro.jpg/220px-San_Siro.jpg
NONE/upload -
http://ja.wikipedia.org/wiki/%E3%82%A4%E3%83%B3%E3%83%86%E3%83%AB%E3%83%8A%E3%83%84%E3%82%A3%E3%82%AA%E3%83%8A%E3%83%BC%E3%83%AC%E3%83%BB%E3%83%9F%E3%83%A9%E3%83%8E
-
Mozilla/5.0%20(compatible;%20MSIE%209.0;%20Windows%20NT%206.1;%20Trident/5.0)
XX';
@@ -67,16 +100,16 @@
# Creating input for test
################################
-open my $sampled_2012_10_01_fh,">$__DATA_BASE/sampled-1000.log-20121001";
-open my $sampled_2012_10_02_fh,">$__DATA_BASE/sampled-1000.log-20121002";
-print $sampled_2012_10_01_fh $contents_2012_10_01;
-print $sampled_2012_10_02_fh $contents_2012_10_02;
-close $sampled_2012_10_01_fh;
-close $sampled_2012_10_02_fh;
+open my $sampled_day_2_fh,">$__DATA_BASE/sampled-1000.log-${day_2_ymd_dense}";
+open my $sampled_day_3_fh,">$__DATA_BASE/sampled-1000.log-${day_3_ymd_dense}";
+print $sampled_day_2_fh $contents_day_2;
+print $sampled_day_3_fh $contents_day_3;
+close $sampled_day_2_fh;
+close $sampled_day_3_fh;
my $wikistats_run_cmd = qq{
- gzip -f $__DATA_BASE/sampled-1000.log-20121001;
- gzip -f $__DATA_BASE/sampled-1000.log-20121002;
+ gzip -f $__DATA_BASE/sampled-1000.log-${day_2_ymd_dense};
+ gzip -f $__DATA_BASE/sampled-1000.log-${day_3_ymd_dense};
echo "FINISHED gzip";
@@ -98,7 +131,7 @@
nice perl
\\
-I ./perl
\\
perl/SquidCountArchive.pl
\\
- -d 2012/10/01-2012/10/01
\\
+ -d $day_2_ymd_slash-$day_2_ymd_slash
\\
-r
testdata/regression-test-ipv6-wrong-external-domain/SquidCountArchiveConfig.pm
\\
-p 2>&1;
@@ -108,7 +141,7 @@
########################
nice perl perl/SquidReportArchive.pl
\\
-r
testdata/regression-test-ipv6-wrong-external-domain/SquidReportArchiveConfig.pm
\\
- -m 2012-10
\\
+ -m $day_2_ym
\\
-p 2>&1;
};
@@ -127,7 +160,7 @@
#######################################################
my $ERRONEOUS_DOMAIN_NAME = "240f";
-my $path_to_origins_csv =
"$__DATA_BASE/csv/2012-10/2012-10-01/public/SquidDataOrigins.csv";
+my $path_to_origins_csv =
"$__DATA_BASE/csv/$day_2_ym/$day_2_ymd/public/SquidDataOrigins.csv";
my $external_domains_240f_count = `cat $path_to_origins_csv | grep
"external,$ERRONEOUS_DOMAIN_NAME" | wc -l`;
ok(-f $path_to_origins_csv , "Origins CSV found") or
die "[ERROR] Critical, exiting";
diff --git a/squids/t/04-regression-countries-count-arithmetic.t
b/squids/t/04-regression-countries-count-arithmetic.t
index a9b32e5..123cbc4 100644
--- a/squids/t/04-regression-countries-count-arithmetic.t
+++ b/squids/t/04-regression-countries-count-arithmetic.t
@@ -9,6 +9,7 @@
use lib "./t";
use Generate::Squid;
use List::Util qw/sum/;
+use POSIX 'strftime';
#
@@ -29,13 +30,41 @@
my $SAMPLE_URL_MOBILE =
"http://en.m.wikipedia.org/wiki/Manhattan_Project";
my $SAMPLE_URL_MIMETYPE_SVG =
"http://en.wikipedia.org/wiki/File:Great-Lakes-Basin.svg";
+
+# We pick a day and simulate country logs for it. The days must not be
+# older than one year, or otherwise SquidCountArchive.pl will
+# complain. So we resort to the 1st, 2nd, ... day of the previous
+# month. That should always work.
+#
+# We're mostly interested in the 2nd day of the month, and filter for
+# that. The 1st day of the month is just needed to simulate
+# boundaries.
+my @date = gmtime(time);
+$date[4]--; # Set month to previous
+if ($date[4] < 0) {
+ # Month underrun. Make up by borrowing from year.
+ $date[4]+=12;
+ $date[5]--;
+}
+
+# First day of month
+$date[3]=1;
+my $day_1_ymd = strftime('%Y-%m-%d', @date);
+
+# Second day of month. This is the day we're interested in.
+$date[3]++;
+my $day_2_ym = strftime('%Y-%m', @date);
+my $day_2_ymd = strftime('%Y-%m-%d', @date);
+my $day_2_ymd_slash = strftime('%Y/%m/%d', @date);
+
+
################################
# Generating data for test
################################
warn $__DATA_BASE;
my $o = Generate::Squid->new({
- start_date => "2012-09-30" ,
+ start_date => $day_1_ymd,
prefix => "sampled-1000.log-",
output_dir => $__DATA_BASE,
});
@@ -48,10 +77,10 @@
{ code => "GB" , mobile_pageviews => "100", non_mobile_pageviews => "0"
},
);
-# Date is 2012-09-30
+# Date is 1st day of month
$o->generate_line({ geocode=>"--" });
$o->__increase_day;
-# Date is 2012-10-01
+# Date is 2nd day of month
for my $country (@countries_data) {
my $mobile_pageviews = $country->{mobile_pageviews};
@@ -66,7 +95,7 @@
$o->generate_line({ geocode => $country->{code} }) for
(1..$non_mobile_pageviews);
};
$o->__increase_day;
-# Date is 2012-10-02
+# Date is 3rd day of month
$o->generate_line({ geocode=>"--" });
$o->dump_to_disk_and_increase_day;
@@ -112,7 +141,7 @@
nice perl \\
-I ./perl \\
perl/SquidCountArchive.pl \\
- -d 2012/10/01-2012/10/01 \\
+ -d $day_2_ymd_slash-$day_2_ymd_slash \\
-r $__DATA_BASE/SquidCountArchiveConfig.pm \\
-p 2>&1;
@@ -122,7 +151,7 @@
########################
nice perl perl/SquidReportArchive.pl \\
-r $__DATA_BASE/SquidReportArchiveConfig.pm \\
- -m 2012-10 \\
+ -m $day_2_ym \\
-p 2>&1;
};
@@ -139,7 +168,7 @@
my $sum_csv;
my $sum_planned=sum(map { $_->{non_mobile_pageviews} + $_->{mobile_pageviews}
} @countries_data);
-open my
$countries_views_csv_fh,"<$__DATA_BASE/csv/2012-10/2012-10-01/public/SquidDataCountriesViews.csv";
+open my
$countries_views_csv_fh,"<$__DATA_BASE/csv/$day_2_ym/$day_2_ymd/public/SquidDataCountriesViews.csv";
while(my $line=<$countries_views_csv_fh>) {
chomp $line;
my @fields = split(/,/,$line);
@@ -164,7 +193,7 @@
use HTML::TreeBuilder::XPath;
use Data::Dumper;
my $p = HTML::TreeBuilder::XPath->new;
-$p->parse_file("$__DATA_BASE/reports/2012-10/SquidReportRequests.htm");
+$p->parse_file("$__DATA_BASE/reports/$day_2_ym/SquidReportRequests.htm");
my @table_1_row_header = $p->findnodes("/html/body/p[1]/table/tr[1]/*");
my @table_1_row_1 = $p->findnodes("/html/body/p[1]/table/tr[3]/*");
my @table_1_row_total = $p->findnodes("/html/body/p[1]/table/tr[4]/*");
diff --git a/squids/t/06-regression-mismatch-world-north-south-unknown.t
b/squids/t/06-regression-mismatch-world-north-south-unknown.t
index d8a3933..98b8837 100644
--- a/squids/t/06-regression-mismatch-world-north-south-unknown.t
+++ b/squids/t/06-regression-mismatch-world-north-south-unknown.t
@@ -10,6 +10,7 @@
use Generate::Squid;
use List::Util qw/sum first/;
use Data::Dumper;
+use POSIX 'strftime';
#
@@ -22,8 +23,32 @@
our $__DATA_BASE;
our $__CODE_BASE;
+# We pick two days and simulate squid/varnish log output for
+# them. The days must not be older than one year, or otherwise
+# SquidCountArchive.pl will complain. So we resort to the 1st,
+# 2nd, ... day of the previous month. That should always work.
+#
+# We're mostly interested in the 2nd day of the month, and filter for
+# that. The 1st day of the month is just there to simulate boundaries.
+my @date = gmtime(time);
+$date[4]--; # Set month to previous
+if ($date[4] < 0) {
+ # Month underrun. Make up by borrowing from year.
+ $date[4]+=12;
+ $date[5]--;
+}
+
+# First day of month
+$date[3]=1;
+my $day_1_ymd = strftime('%Y-%m-%d', @date);
+
+# Second day of month. This is the day we're interested in.
+$date[3]++;
+my $day_2_ym = strftime('%Y-%m', @date);
+my $day_2_ymd_slash = strftime('%Y/%m/%d', @date);
+
my $o = Generate::Squid->new({
- start_date => "2012-09-30" ,
+ start_date => $day_1_ymd,
prefix => "sampled-1000.log-" ,
output_dir => "$__DATA_BASE",
});
@@ -72,7 +97,7 @@
nice perl \\
-I ./perl \\
perl/SquidCountArchive.pl \\
- -d 2012/10/01-2012/10/01 \\
+ -d $day_2_ymd_slash-$day_2_ymd_slash \\
-r $__DATA_BASE/SquidCountArchiveConfig.pm \\
-p 2>&1;
@@ -82,7 +107,7 @@
########################
nice perl perl/SquidReportArchive.pl \\
-r $__DATA_BASE/SquidReportArchiveConfig.pm \\
- -m 2012-10 \\
+ -m $day_2_ym \\
-p 2>&1;
};
@@ -95,7 +120,7 @@
use HTML::TreeBuilder::XPath;
use Data::Dumper;
my $p = HTML::TreeBuilder::XPath->new;
-$p->parse_file("$__DATA_BASE/reports/2012-10/SquidReportCountryData.htm");
+$p->parse_file("$__DATA_BASE/reports/$day_2_ym/SquidReportCountryData.htm");
my @nodes;
diff --git a/squids/t/08-regression-tablets-discrepancy_for_config_editors.t
b/squids/t/08-regression-tablets-discrepancy_for_config_editors.t
index 49c84b4..aebeb36 100644
--- a/squids/t/08-regression-tablets-discrepancy_for_config_editors.t
+++ b/squids/t/08-regression-tablets-discrepancy_for_config_editors.t
@@ -9,6 +9,7 @@
use lib "./t";
use Generate::Squid;
use List::Util qw/sum/;
+use POSIX 'strftime';
my $SAMPLE_UA_TABLET_ANDROID_MOZILLA =
"Mozilla/5.0%20(Android;%20Tablet;%20rv:10.0.5)%20Gecko/10.0.5%20Firefox/10.0.5%20Fennec/10.0.5";
my $SAMPLE_UA_TABLET_IPAD_SAFARI =
"Mozilla/5.0%20(iPad;%20CPU%20iPhone%20OS%205_0_1%20like%20Mac%20OS%20X)%20AppleWebKit/534.46%20(KHTML,%20like%20Gecko)%20Version/5.1%20Mobile/9A405%20Safari/7534.48.3";
my $SAMPLE_UA_TABLET_ANDROID_OPERA =
"Opera/9.80%20(Android%202.1.1;%20Linux;%20Opera%20Tablet/ADR-1106291546;%20U;%20ru)%20Presto/2.8.149%20Version/11.10";
@@ -25,8 +26,32 @@
our $__DATA_BASE;
our $__CODE_BASE;
+# We pick two days and simulate squid/varnish log output for
+# them. The days must not be older than one year, or otherwise
+# SquidCountArchive.pl will complain. So we resort to the 1st,
+# 2nd, ... day of the previous month. That should always work.
+#
+# We're mostly interested in the 2nd day of the month, and filter for
+# that. The 1st day of the month is just there to simulate boundaries.
+my @date = gmtime(time);
+$date[4]--; # Set month to previous
+if ($date[4] < 0) {
+ # Month underrun. Make up by borrowing from year.
+ $date[4]+=12;
+ $date[5]--;
+}
+
+# First day of month
+$date[3]=1;
+my $day_1_ymd = strftime('%Y-%m-%d', @date);
+
+# Second day of month. This is the day we're interested in.
+$date[3]++;
+my $day_2_ym = strftime('%Y-%m', @date);
+my $day_2_ymd_slash = strftime('%Y/%m/%d', @date);
+
my $o = Generate::Squid->new({
- start_date => "2012-09-30" ,
+ start_date => "$day_1_ymd",
prefix => "sampled-1000.log-" ,
output_dir => "$__DATA_BASE",
});
@@ -75,7 +100,7 @@
nice perl \\
-I ./perl \\
perl/SquidCountArchive.pl \\
- -d 2012/10/01-2012/10/01 \\
+ -d $day_2_ymd_slash-$day_2_ymd_slash \\
-r $__DATA_BASE/SquidCountArchiveConfig.pm \\
-p 2>&1;
@@ -86,7 +111,7 @@
########################
nice perl perl/SquidReportArchive.pl \\
-r $__DATA_BASE/SquidReportArchiveConfig.pm \\
- -m 2012-10 \\
+ -m $day_2_ym \\
-p 2>&1;
};
@@ -98,7 +123,7 @@
use HTML::TreeBuilder::XPath;
my @nodes;
my $p = HTML::TreeBuilder::XPath->new;
-$p->parse_file("$__DATA_BASE/reports/2012-10/SquidReportClients.htm");
+$p->parse_file("$__DATA_BASE/reports/$day_2_ym/SquidReportClients.htm");
@nodes = map { $_ }
$p->findnodes("//html/body/p[1]/table/tr[2]/td[1]/table/tr[5]");
diff --git a/squids/t/11-merge-australia-into-oceania.t
b/squids/t/11-merge-australia-into-oceania.t
index 1676682..949c255 100644
--- a/squids/t/11-merge-australia-into-oceania.t
+++ b/squids/t/11-merge-australia-into-oceania.t
@@ -9,6 +9,7 @@
use lib "./t";
use Generate::Squid;
use List::Util qw/sum/;
+use POSIX 'strftime';
our $__DATA_BASE;
our $__CODE_BASE;
@@ -20,8 +21,32 @@
system("ls testdata/");
system('echo
"==============================================================="');
+# We pick two days and simulate squid/varnish log output for
+# them. The days must not be older than one year, or otherwise
+# SquidCountArchive.pl will complain. So we resort to the 1st,
+# 2nd, ... day of the previous month. That should always work.
+#
+# We're mostly interested in the 2nd day of the month, and filter for
+# that. The 1st day of the month is just there to simulate boundaries.
+my @date = gmtime(time);
+$date[4]--; # Set month to previous
+if ($date[4] < 0) {
+ # Month underrun. Make up by borrowing from year.
+ $date[4]+=12;
+ $date[5]--;
+}
+
+# First day of month
+$date[3]=1;
+my $day_1_ymd = strftime('%Y-%m-%d', @date);
+
+# Second day of month. This is the day we're interested in.
+$date[3]++;
+my $day_2_ym = strftime('%Y-%m', @date);
+my $day_2_ymd_slash = strftime('%Y/%m/%d', @date);
+
my $o = Generate::Squid->new({
- start_date => "2012-09-30" ,
+ start_date => $day_1_ymd,
prefix => "sampled-1000.log-" ,
output_dir => "$__DATA_BASE",
});
@@ -62,7 +87,7 @@
nice perl \\
-I ./perl \\
perl/SquidCountArchive.pl \\
- -d 2012/10/01-2012/10/01 \\
+ -d $day_2_ymd_slash-$day_2_ymd_slash \\
-r $__DATA_BASE/SquidCountArchiveConfig.pm \\
-p 2>&1;
@@ -72,14 +97,14 @@
########################
nice perl perl/SquidReportArchive.pl \\
-r $__DATA_BASE/SquidReportArchiveConfig.pm \\
- -m 2012-10 \\
+ -m $day_2_ym \\
-p 2>&1;
};
my $wikistats_run_cmd_output = `$wikistats_run_cmd`;
#warn $wikistats_run_cmd_output;
-my $SquidReportCountryData = `cat
$__DATA_BASE/reports/2012-10/SquidReportCountryData.htm`;
+my $SquidReportCountryData = `cat
$__DATA_BASE/reports/$day_2_ym/SquidReportCountryData.htm`;
ok($SquidReportCountryData !~ /All countries in.*Australia/,"Australia is not
a region anymore");
ok($SquidReportCountryData =~ /Australia.*Oceania/ , "Australia is under the
Oceania region now");
--
To view, visit https://gerrit.wikimedia.org/r/102292
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bf3d54c35665bd9ebec53ce9658141fa9a1983b
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikistats
Gerrit-Branch: master
Gerrit-Owner: QChris <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits