@@ -1592,6 +1592,142 @@ func TestValidateRayJobSpecWithFeatureGate(t *testing.T) {
15921592 },
15931593 expectError : false ,
15941594 },
1595+ {
1596+ name : "valid deletionRules with JobDeploymentStatus=Failed" ,
1597+ spec : rayv1.RayJobSpec {
1598+ DeletionStrategy : & rayv1.DeletionStrategy {
1599+ DeletionRules : []rayv1.DeletionRule {
1600+ {
1601+ Policy : rayv1 .DeleteCluster ,
1602+ Condition : rayv1.DeletionCondition {
1603+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1604+ TTLSeconds : 10 ,
1605+ },
1606+ },
1607+ {
1608+ Policy : rayv1 .DeleteSelf ,
1609+ Condition : rayv1.DeletionCondition {
1610+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1611+ TTLSeconds : 20 ,
1612+ },
1613+ },
1614+ },
1615+ },
1616+ RayClusterSpec : createBasicRayClusterSpec (),
1617+ },
1618+ expectError : false ,
1619+ },
1620+ {
1621+ name : "invalid: both JobStatus and JobDeploymentStatus set" ,
1622+ spec : rayv1.RayJobSpec {
1623+ DeletionStrategy : & rayv1.DeletionStrategy {
1624+ DeletionRules : []rayv1.DeletionRule {
1625+ {
1626+ Policy : rayv1 .DeleteCluster ,
1627+ Condition : rayv1.DeletionCondition {
1628+ JobStatus : ptr .To (rayv1 .JobStatusFailed ),
1629+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1630+ TTLSeconds : 10 ,
1631+ },
1632+ },
1633+ },
1634+ },
1635+ RayClusterSpec : createBasicRayClusterSpec (),
1636+ },
1637+ expectError : true ,
1638+ },
1639+ {
1640+ name : "invalid: neither JobStatus nor JobDeploymentStatus set" ,
1641+ spec : rayv1.RayJobSpec {
1642+ DeletionStrategy : & rayv1.DeletionStrategy {
1643+ DeletionRules : []rayv1.DeletionRule {
1644+ {
1645+ Policy : rayv1 .DeleteCluster ,
1646+ Condition : rayv1.DeletionCondition {
1647+ TTLSeconds : 10 ,
1648+ },
1649+ },
1650+ },
1651+ },
1652+ RayClusterSpec : createBasicRayClusterSpec (),
1653+ },
1654+ expectError : true ,
1655+ },
1656+ {
1657+ name : "duplicate rule with JobDeploymentStatus" ,
1658+ spec : rayv1.RayJobSpec {
1659+ DeletionStrategy : & rayv1.DeletionStrategy {
1660+ DeletionRules : []rayv1.DeletionRule {
1661+ {
1662+ Policy : rayv1 .DeleteCluster ,
1663+ Condition : rayv1.DeletionCondition {
1664+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1665+ TTLSeconds : 10 ,
1666+ },
1667+ },
1668+ {
1669+ Policy : rayv1 .DeleteCluster ,
1670+ Condition : rayv1.DeletionCondition {
1671+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1672+ TTLSeconds : 20 ,
1673+ },
1674+ },
1675+ },
1676+ },
1677+ RayClusterSpec : createBasicRayClusterSpec (),
1678+ },
1679+ expectError : true ,
1680+ },
1681+ {
1682+ name : "valid: mixed JobStatus and JobDeploymentStatus rules" ,
1683+ spec : rayv1.RayJobSpec {
1684+ DeletionStrategy : & rayv1.DeletionStrategy {
1685+ DeletionRules : []rayv1.DeletionRule {
1686+ {
1687+ Policy : rayv1 .DeleteWorkers ,
1688+ Condition : rayv1.DeletionCondition {
1689+ JobStatus : ptr .To (rayv1 .JobStatusFailed ),
1690+ TTLSeconds : 10 ,
1691+ },
1692+ },
1693+ {
1694+ Policy : rayv1 .DeleteCluster ,
1695+ Condition : rayv1.DeletionCondition {
1696+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1697+ TTLSeconds : 20 ,
1698+ },
1699+ },
1700+ },
1701+ },
1702+ RayClusterSpec : createBasicRayClusterSpec (),
1703+ },
1704+ expectError : false ,
1705+ },
1706+ {
1707+ name : "inconsistent TTLs with JobDeploymentStatus (DeleteCluster < DeleteWorkers)" ,
1708+ spec : rayv1.RayJobSpec {
1709+ DeletionStrategy : & rayv1.DeletionStrategy {
1710+ DeletionRules : []rayv1.DeletionRule {
1711+ {
1712+ Policy : rayv1 .DeleteWorkers ,
1713+ Condition : rayv1.DeletionCondition {
1714+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1715+ TTLSeconds : 20 ,
1716+ },
1717+ },
1718+ {
1719+ Policy : rayv1 .DeleteCluster ,
1720+ Condition : rayv1.DeletionCondition {
1721+ JobDeploymentStatus : ptr .To (rayv1 .JobDeploymentStatusFailed ),
1722+ TTLSeconds : 10 ,
1723+ },
1724+ },
1725+ },
1726+ },
1727+ RayClusterSpec : createBasicRayClusterSpec (),
1728+ },
1729+ expectError : true ,
1730+ },
15951731 }
15961732
15971733 features .SetFeatureGateDuringTest (t , features .RayJobDeletionPolicy , true )
0 commit comments