@@ -19,9 +19,10 @@ BEGIN {
19
19
}
20
20
21
21
use Capture::Tiny qw( capture) ;
22
- use QA::Util qw( get_config) ;
23
- use MIME::Base64 qw( encode_base64 decode_base64) ;
24
- use Mojo::JSON qw( false) ;
22
+ use DateTime;
23
+ use QA::Util qw( get_config) ;
24
+ use MIME::Base64 qw( encode_base64 decode_base64) ;
25
+ use Mojo::JSON qw( false) ;
25
26
use Test::Mojo;
26
27
use Test::More;
27
28
@@ -30,6 +31,7 @@ my $admin_login = $config->{admin_user_login};
30
31
my $admin_api_key = $config -> {admin_user_api_key };
31
32
my $editbugs_api_key = $config -> {editbugs_user_api_key };
32
33
my $url = Bugzilla-> localconfig-> urlbase;
34
+ my $snapshot_date = DateTime-> now()-> strftime(' %Y-%m-%d' );
33
35
34
36
my $t = Test::Mojo-> new();
35
37
@@ -60,9 +62,13 @@ $t->post_ok($url
60
62
my $bug_id_1 = $t -> tx-> res-> json-> {id };
61
63
62
64
# Clear the needinfo which will add an X entry in flag_state_activity
65
+ my $needinfo_update = {
66
+ comment => {body => ' This is my comment' },
67
+ flags => [{name => ' needinfo' , status => ' X' }],
68
+ };
63
69
$t -> put_ok($url
64
70
. " rest/bug/$bug_id_1 " => {' X-Bugzilla-API-Key' => $editbugs_api_key } =>
65
- json => { comment => { body => ' This is my comment ' }} )-> status_is(200);
71
+ json => $needinfo_update )-> status_is(200);
66
72
67
73
# ## Section 2: Create a new dependent bug
68
74
@@ -114,19 +120,19 @@ my ($attach_id) = keys %{$t->tx->res->json->{attachments}};
114
120
115
121
my @cmd = (
116
122
' ./extensions/BMO/bin/export_bmo_etl.pl' ,
117
- ' --verbose' , ' --test' , ' --snapshot-date' , ' 2000-01-01 '
123
+ ' --verbose' , ' --test' , ' --snapshot-date' , $snapshot_date ,
118
124
);
119
125
120
126
my ($output , $error , $rv ) = capture { system @cmd ; };
121
127
ok(!$rv , ' Data exported to test files without error' );
122
- ok(glob (bz_locations()-> {' datadir' } . ' /2000-01-01 -bugs-*.json' ),
128
+ ok(glob (bz_locations()-> {' datadir' } . ' /' . $snapshot_date . ' -bugs-*.json' ),
123
129
' Export test files exist' );
124
130
125
131
# ## Section 5: Export data to BigQuery test instance
126
132
127
133
@cmd = (
128
- ' ./extensions/BMO/bin/export_bmo_etl.pl' , ' --verbose ' ,
129
- ' --snapshot-date ' , ' 2000-01-01 '
134
+ ' ./extensions/BMO/bin/export_bmo_etl.pl' ,
135
+ ' --verbose ' , ' --snapshot-date ' , $snapshot_date ,
130
136
);
131
137
132
138
($output , $error , $rv ) = capture { system @cmd ; };
@@ -135,7 +141,10 @@ ok(!$rv, 'Data exported to BigQuery test instance without error');
135
141
# ## Section 6: Retrieve data from BigQuery instance and verify
136
142
137
143
my $query = {
138
- query => ' SELECT summary FROM test.bugzilla.bugs WHERE id = ' . $bug_id_1 . ' ;' ,
144
+ query => ' SELECT summary FROM test.bugzilla.bugs WHERE id = '
145
+ . $bug_id_1
146
+ . ' AND snapshot_date = \' '
147
+ . $snapshot_date . ' \' ;' ,
139
148
useLegacySql => false
140
149
};
141
150
$t -> post_ok(
@@ -144,7 +153,9 @@ $t->post_ok(
144
153
145
154
$query = {
146
155
query => ' SELECT description FROM test.bugzilla.attachments WHERE id = '
147
- . $attach_id . ' ;' ,
156
+ . $attach_id
157
+ . ' AND snapshot_date = \' '
158
+ . $snapshot_date . ' \' ;' ,
148
159
useLegacySql => false
149
160
};
150
161
$t -> post_ok(
@@ -154,7 +165,9 @@ $t->post_ok(
154
165
$query = {
155
166
query =>
156
167
' SELECT depends_on_id FROM test.bugzilla.bug_dependencies WHERE bug_id = '
157
- . $bug_id_2 . ' ;' ,
168
+ . $bug_id_2
169
+ . ' AND snapshot_date = \' '
170
+ . $snapshot_date . ' \' ;' ,
158
171
useLegacySql => false
159
172
};
160
173
$t -> post_ok(
@@ -163,7 +176,9 @@ $t->post_ok(
163
176
164
177
$query = {
165
178
query => ' SELECT bug_id FROM test.bugzilla.flags WHERE bug_id = '
166
- . $bug_id_1 . " AND name = 'needinfo';" ,
179
+ . $bug_id_1
180
+ . ' AND name = \' needinfo\' AND value = \' X\' AND snapshot_date = \' '
181
+ . $snapshot_date . ' \' ' ,
167
182
useLegacySql => false
168
183
};
169
184
$t -> post_ok(
@@ -173,8 +188,10 @@ $t->post_ok(
173
188
$query = {
174
189
query => ' SELECT bug_id FROM test.bugzilla.flags WHERE bug_id = '
175
190
. $bug_id_1
176
- . " AND name = 'review' AND attachment_id = "
177
- . $attach_id . ' ;' ,
191
+ . ' AND name = \' review\' AND attachment_id = '
192
+ . $attach_id
193
+ . ' AND snapshot_date = \' '
194
+ . $snapshot_date . ' \' ;' ,
178
195
useLegacySql => false
179
196
};
180
197
@@ -185,8 +202,8 @@ $t->post_ok(
185
202
# ## Section 7: Exporting again on the same day (with the same snapshot date) will cause the script to exit
186
203
187
204
@cmd = (
188
- ' ./extensions/BMO/bin/export_bmo_etl.pl' , ' --verbose ' ,
189
- ' --snapshot-date ' , ' 2000-01-01 ' ,
205
+ ' ./extensions/BMO/bin/export_bmo_etl.pl' ,
206
+ ' --verbose ' , ' --snapshot-date ' , $snapshot_date ,
190
207
);
191
208
192
209
($output , $error , $rv ) = capture { system @cmd ; };
0 commit comments