@@ -653,7 +653,6 @@ public void testPutJob_ThrowsIfIdIsTheSameAsAGroup() throws IOException {
653
653
MockClientBuilder mockClientBuilder = new MockClientBuilder ("jobmanager-test" );
654
654
JobManager jobManager = createJobManager (mockClientBuilder .build ());
655
655
656
- PutJobAction .Request putJobRequest = new PutJobAction .Request (createJobFoo ());
657
656
658
657
MlMetadata .Builder mlMetadata = new MlMetadata .Builder ();
659
658
Job .Builder jobBuilder = buildJobBuilder ("job-with-group-foo" );
@@ -662,6 +661,8 @@ public void testPutJob_ThrowsIfIdIsTheSameAsAGroup() throws IOException {
662
661
ClusterState clusterState = ClusterState .builder (new ClusterName ("name" ))
663
662
.metaData (MetaData .builder ().putCustom (MlMetadata .TYPE , mlMetadata .build ())).build ();
664
663
664
+ // job id cannot be a group
665
+ PutJobAction .Request putJobRequest = new PutJobAction .Request (createJobFoo ());
665
666
jobManager .putJob (putJobRequest , analysisRegistry , clusterState , new ActionListener <PutJobAction .Response >() {
666
667
@ Override
667
668
public void onResponse (PutJobAction .Response response ) {
@@ -674,6 +675,26 @@ public void onFailure(Exception e) {
674
675
assertEquals ("job and group names must be unique but job [foo] and group [foo] have the same name" , e .getMessage ());
675
676
}
676
677
});
678
+
679
+ // the job's groups cannot be job Ids
680
+ jobBuilder = buildJobBuilder ("job-with-clashing-group-name" );
681
+ jobBuilder .setCreateTime (null );
682
+ jobBuilder .setGroups (Collections .singletonList ("job-with-group-foo" ));
683
+ putJobRequest = new PutJobAction .Request (jobBuilder );
684
+
685
+ jobManager .putJob (putJobRequest , analysisRegistry , clusterState , new ActionListener <PutJobAction .Response >() {
686
+ @ Override
687
+ public void onResponse (PutJobAction .Response response ) {
688
+ fail ("should have got an error" );
689
+ }
690
+
691
+ @ Override
692
+ public void onFailure (Exception e ) {
693
+ assertTrue (e instanceof ResourceAlreadyExistsException );
694
+ assertEquals ("job and group names must be unique but job [job-with-group-foo] and " +
695
+ "group [job-with-group-foo] have the same name" , e .getMessage ());
696
+ }
697
+ });
677
698
}
678
699
679
700
public void testNotifyFilterChangedGivenNoop () {
0 commit comments