55import 'package:cocoon_common/rpc_model.dart' as rpc;
66import 'package:cocoon_common/task_status.dart' ;
77import 'package:cocoon_server_test/test_logging.dart' ;
8+ import 'package:cocoon_service/src/model/commit_ref.dart' ;
89import 'package:cocoon_service/src/request_handlers/scheduler/backfill_grid.dart' ;
910import 'package:cocoon_service/src/request_handlers/scheduler/backfill_strategy.dart' ;
1011import 'package:cocoon_service/src/request_handlers/scheduler/batch_backfiller.dart' ;
1112import 'package:cocoon_service/src/service/config.dart' ;
1213import 'package:cocoon_service/src/service/luci_build_service.dart' ;
14+ import 'package:cocoon_service/src/service/luci_build_service/pending_task.dart' ;
1315import 'package:collection/collection.dart' ;
1416import 'package:github/github.dart' ;
1517import 'package:mockito/mockito.dart' ;
1618import 'package:test/test.dart' ;
1719
1820import '../../src/fake_config.dart' ;
19- import '../../src/request_handling/fake_pubsub.dart' ;
2021import '../../src/request_handling/request_handler_tester.dart' ;
2122import '../../src/service/fake_ci_yaml_fetcher.dart' ;
2223import '../../src/service/fake_firestore_service.dart' ;
23- import '../../src/service/fake_luci_build_service.dart' ;
2424import '../../src/utilities/entity_generators.dart' ;
2525import '../../src/utilities/mocks.mocks.dart' ;
2626
@@ -31,11 +31,10 @@ void main() {
3131 late BatchBackfiller handler;
3232
3333 // Dependencies.
34- late FakePubSub pubSub;
35- late MockGithubChecksUtil mockGithubChecksUtil;
3634 late FakeConfig config;
3735 late FakeFirestoreService firestore;
3836 late FakeCiYamlFetcher ciYamlFetcher;
37+ late _FakeLuciBuildService fakeLuciBuildService;
3938
4039 // Used to implement BranchService.getBranches.
4140 late List <rpc.Branch >? branchesForRepository;
@@ -44,22 +43,14 @@ void main() {
4443 late RequestHandlerTester tester;
4544
4645 setUp (() {
47- pubSub = FakePubSub ();
48- mockGithubChecksUtil = MockGithubChecksUtil ();
4946 firestore = FakeFirestoreService ();
5047 config = FakeConfig (
5148 backfillerCommitLimitValue: 10 ,
5249 backfillerTargetLimitValue: 100 ,
5350 supportedReposValue: {Config .flutterSlug},
5451 );
5552 ciYamlFetcher = FakeCiYamlFetcher ();
56-
57- final luciBuildService = FakeLuciBuildService (
58- config: config,
59- pubsub: pubSub,
60- githubChecksUtil: mockGithubChecksUtil,
61- firestore: firestore,
62- );
53+ fakeLuciBuildService = _FakeLuciBuildService ();
6354
6455 final branchService = MockBranchService ();
6556 branchesForRepository = [];
@@ -79,7 +70,7 @@ void main() {
7970 handler = BatchBackfiller (
8071 config: config,
8172 ciYamlFetcher: ciYamlFetcher,
82- luciBuildService: luciBuildService ,
73+ luciBuildService: fakeLuciBuildService ,
8374 backfillerStrategy: const _NaiveBackfillStrategy (),
8475 firestore: firestore,
8576 branchService: branchService,
@@ -362,6 +353,59 @@ void main() {
362353 ]);
363354 // dart format on
364355 });
356+
357+ // https://github.com/flutter/flutter/issues/168738
358+ test ('schedules low-priority targets for "ios-experimental"' , () async {
359+ branchesForRepository = [
360+ // Intentionally left blank.
361+ ];
362+
363+ // dart format off
364+ await fillStorageAndSetCiYaml ([
365+ [$N , $I , $F , $S ],
366+ [$N , $N , $N , $N ],
367+ ], branch: 'ios-experimental' );
368+ // dart format on
369+
370+ // BEFORE:
371+ expect (
372+ await visualizeFirestoreGrid (commits: 2 , branch: 'ios-experimental' ),
373+ // dart format off
374+ [
375+ '🧑💼 ⬜ 🟨 🟥 🟩' ,
376+ '🧑💼 ⬜ ⬜ ⬜ ⬜' ,
377+ ],
378+ // dart format on
379+ );
380+
381+ await tester.get (handler);
382+
383+ // AFTER:
384+ expect (
385+ await visualizeFirestoreGrid (commits: 2 , branch: 'ios-experimental' ),
386+ // dart format off
387+ [
388+ '🧑💼 🟨 🟨 🟥 🟩' ,
389+ '🧑💼 ⬜ 🟨 🟨 🟨' ,
390+ ],
391+ // dart format on
392+ );
393+
394+ expect (
395+ fakeLuciBuildService.scheduledPostsubmitBuilds,
396+ allOf (
397+ hasLength (4 ),
398+ everyElement (
399+ isA <PendingTask >().having (
400+ (t) => t.priority,
401+ 'priority' ,
402+ LuciBuildService .kBackfillPriority,
403+ ),
404+ ),
405+ ),
406+ reason: 'Should use a low priority for all executions' ,
407+ );
408+ });
365409}
366410
367411/// A very hermetic but dumb backfilling algorithm.
@@ -385,3 +429,16 @@ final class _NaiveBackfillStrategy extends BackfillStrategy {
385429 ];
386430 }
387431}
432+
433+ final class _FakeLuciBuildService extends Fake implements LuciBuildService {
434+ final scheduledPostsubmitBuilds = < PendingTask > [];
435+
436+ @override
437+ Future <List <PendingTask >> schedulePostsubmitBuilds ({
438+ required CommitRef commit,
439+ required List <PendingTask > toBeScheduled,
440+ }) async {
441+ scheduledPostsubmitBuilds.addAll (toBeScheduled);
442+ return [];
443+ }
444+ }
0 commit comments