|
22 | 22 | import org.apache.hadoop.util.Time; |
23 | 23 | import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; |
24 | 24 | import org.apache.hadoop.yarn.api.records.ApplicationId; |
| 25 | +import org.apache.hadoop.yarn.api.records.QueueState; |
25 | 26 | import org.apache.hadoop.yarn.conf.YarnConfiguration; |
26 | 27 | import org.apache.hadoop.yarn.exceptions.YarnException; |
27 | 28 | import org.apache.hadoop.yarn.server.resourcemanager.MockNM; |
@@ -968,6 +969,66 @@ public void testQueueInfoIfAmbiguousQueueNames() throws Exception { |
968 | 969 | bAutoLeafQueue.getQueueInfo().getQueueName()); |
969 | 970 | } |
970 | 971 |
|
| 972 | + @Test |
| 973 | + public void testRemoveDanglingAutoCreatedQueuesOnReinit() throws Exception { |
| 974 | + startScheduler(); |
| 975 | + |
| 976 | + // Validate static parent deletion |
| 977 | + createQueue("root.a.a-auto"); |
| 978 | + AbstractCSQueue aAuto = (AbstractCSQueue) cs. |
| 979 | + getQueue("root.a.a-auto"); |
| 980 | + Assert.assertTrue(aAuto.isDynamicQueue()); |
| 981 | + |
| 982 | + csConf.setState("root.a", QueueState.STOPPED); |
| 983 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 984 | + aAuto = (AbstractCSQueue) cs. |
| 985 | + getQueue("root.a.a-auto"); |
| 986 | + Assert.assertEquals("root.a.a-auto is not in STOPPED state", QueueState.STOPPED, aAuto.getState()); |
| 987 | + csConf.setQueues("root", new String[]{"b"}); |
| 988 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 989 | + CSQueue aAutoNew = cs.getQueue("root.a.a-auto"); |
| 990 | + Assert.assertNull(aAutoNew); |
| 991 | + |
| 992 | + submitApp(cs, USER0, "a-auto", "root.a"); |
| 993 | + aAutoNew = cs.getQueue("root.a.a-auto"); |
| 994 | + Assert.assertNotNull(aAutoNew); |
| 995 | + |
| 996 | + // Validate static grandparent deletion |
| 997 | + csConf.setQueues("root", new String[]{"a", "b"}); |
| 998 | + csConf.setQueues("root.a", new String[]{"a1"}); |
| 999 | + csConf.setAutoQueueCreationV2Enabled("root.a.a1", true); |
| 1000 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 1001 | + |
| 1002 | + createQueue("root.a.a1.a1-auto"); |
| 1003 | + CSQueue a1Auto = cs.getQueue("root.a.a1.a1-auto"); |
| 1004 | + Assert.assertNotNull("a1-auto should exist", a1Auto); |
| 1005 | + |
| 1006 | + csConf.setQueues("root", new String[]{"b"}); |
| 1007 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 1008 | + a1Auto = cs.getQueue("root.a.a1.a1-auto"); |
| 1009 | + Assert.assertNull("a1-auto has no parent and should not exist", a1Auto); |
| 1010 | + |
| 1011 | + // Validate dynamic parent deletion |
| 1012 | + csConf.setState("root.b", QueueState.STOPPED); |
| 1013 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 1014 | + csConf.setAutoQueueCreationV2Enabled("root.b", true); |
| 1015 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 1016 | + |
| 1017 | + createQueue("root.b.b-auto-parent.b-auto-leaf"); |
| 1018 | + CSQueue bAutoParent = cs.getQueue("root.b.b-auto-parent"); |
| 1019 | + Assert.assertNotNull("b-auto-parent should exist", bAutoParent); |
| 1020 | + ParentQueue b = (ParentQueue) cs.getQueue("root.b"); |
| 1021 | + b.removeChildQueue(bAutoParent); |
| 1022 | + |
| 1023 | + cs.reinitialize(csConf, mockRM.getRMContext()); |
| 1024 | + |
| 1025 | + bAutoParent = cs.getQueue("root.b.b-auto-parent"); |
| 1026 | + Assert.assertNull("b-auto-parent should not exist ", bAutoParent); |
| 1027 | + CSQueue bAutoLeaf = cs.getQueue("root.b.b-auto-parent.b-auto-leaf"); |
| 1028 | + Assert.assertNull("b-auto-leaf should not exist " + |
| 1029 | + "when its dynamic parent is removed", bAutoLeaf); |
| 1030 | + } |
| 1031 | + |
971 | 1032 | protected LeafQueue createQueue(String queuePath) throws YarnException { |
972 | 1033 | return autoQueueHandler.autoCreateQueue( |
973 | 1034 | CSQueueUtils.extractQueuePath(queuePath)); |
|
0 commit comments