@@ -1648,121 +1648,6 @@ func TestAddApplicationsWithTags(t *testing.T) {
16481648 }
16491649}
16501650
1651- func TestPendingPodAllocations (t * testing.T ) {
1652- utils .SetPluginMode (true )
1653- defer utils .SetPluginMode (false )
1654-
1655- context , apiProvider := initContextAndAPIProviderForTest ()
1656- dispatcher .Start ()
1657- defer dispatcher .UnregisterAllEventHandlers ()
1658- defer dispatcher .Stop ()
1659-
1660- apiProvider .MockSchedulerAPIUpdateNodeFn (func (request * si.NodeRequest ) error {
1661- for _ , node := range request .Nodes {
1662- dispatcher .Dispatch (CachedSchedulerNodeEvent {
1663- NodeID : node .NodeID ,
1664- Event : NodeAccepted ,
1665- })
1666- }
1667- return nil
1668- })
1669-
1670- node1 := v1.Node {
1671- ObjectMeta : apis.ObjectMeta {
1672- Name : Host1 ,
1673- Namespace : "default" ,
1674- UID : uid1 ,
1675- },
1676- }
1677- context .addNode (& node1 )
1678-
1679- node2 := v1.Node {
1680- ObjectMeta : apis.ObjectMeta {
1681- Name : Host2 ,
1682- Namespace : "default" ,
1683- UID : uid2 ,
1684- },
1685- }
1686- context .addNode (& node2 )
1687-
1688- // add a new application
1689- context .AddApplication (& AddApplicationRequest {
1690- Metadata : ApplicationMetadata {
1691- ApplicationID : appID1 ,
1692- QueueName : queueNameA ,
1693- User : testUser ,
1694- Tags : nil ,
1695- },
1696- })
1697-
1698- pod := & v1.Pod {
1699- TypeMeta : apis.TypeMeta {
1700- Kind : "Pod" ,
1701- APIVersion : "v1" ,
1702- },
1703- ObjectMeta : apis.ObjectMeta {
1704- Name : taskUID1 ,
1705- UID : uid1 ,
1706- },
1707- }
1708-
1709- // add a tasks to the existing application
1710- task := context .AddTask (& AddTaskRequest {
1711- Metadata : TaskMetadata {
1712- ApplicationID : appID1 ,
1713- TaskID : taskUID1 ,
1714- Pod : pod ,
1715- },
1716- })
1717- assert .Assert (t , task != nil , "task was nil" )
1718-
1719- // add the allocation
1720- context .AddPendingPodAllocation (uid1 , Host1 )
1721-
1722- // validate that the pending allocation matches
1723- nodeID , ok := context .GetPendingPodAllocation (uid1 )
1724- if ! ok {
1725- t .Fatalf ("no pending pod allocation found" )
1726- }
1727- assert .Equal (t , nodeID , Host1 , "wrong host" )
1728-
1729- // validate that there is not an in-progress allocation
1730- if _ , ok = context .GetInProgressPodAllocation (uid1 ); ok {
1731- t .Fatalf ("in-progress allocation exists when it should be pending" )
1732- }
1733-
1734- if context .StartPodAllocation (uid1 , Host2 ) {
1735- t .Fatalf ("attempt to start pod allocation on wrong node succeeded" )
1736- }
1737-
1738- if ! context .StartPodAllocation (uid1 , Host1 ) {
1739- t .Fatalf ("attempt to start pod allocation on correct node failed" )
1740- }
1741-
1742- if _ , ok = context .GetPendingPodAllocation (uid1 ); ok {
1743- t .Fatalf ("pending pod allocation still exists after transition to in-progress" )
1744- }
1745-
1746- nodeID , ok = context .GetInProgressPodAllocation (uid1 )
1747- if ! ok {
1748- t .Fatalf ("in-progress allocation does not exist" )
1749- }
1750- assert .Equal (t , nodeID , Host1 , "wrong host" )
1751-
1752- context .RemovePodAllocation (uid1 )
1753- if _ , ok = context .GetInProgressPodAllocation (uid1 ); ok {
1754- t .Fatalf ("in-progress pod allocation still exists after removal" )
1755- }
1756-
1757- // re-add to validate pending pod removal
1758- context .AddPendingPodAllocation (uid1 , Host1 )
1759- context .RemovePodAllocation (uid1 )
1760-
1761- if _ , ok = context .GetPendingPodAllocation (uid1 ); ok {
1762- t .Fatalf ("pending pod allocation still exists after removal" )
1763- }
1764- }
1765-
17661651func TestGetStateDump (t * testing.T ) {
17671652 context := initContextForTest ()
17681653
0 commit comments