@@ -1813,5 +1813,152 @@ var _ = Describe("The Pod Placement Operand", func() {
18131813 By ("The pod should be running" )
18141814 Eventually (framework .VerifyPodsAreRunning (ctx , client , ns , "app" , "test" ), e2e .WaitShort ).Should (Succeed ())
18151815 })
1816+ It ("Should set node affinity when image has digest and port" , func () {
1817+ var err error
1818+ By ("Create an ephemeral namespace" )
1819+ ns := framework .NewEphemeralNamespace ()
1820+ err = client .Create (ctx , ns )
1821+ Expect (err ).NotTo (HaveOccurred ())
1822+ //nolint:errcheck
1823+ defer client .Delete (ctx , ns )
1824+ By ("Create a deployment running image in source registry" )
1825+ ps := NewPodSpec ().
1826+ WithContainersImages (e2e .HelloopenshiftPublicMultiarchImageWithPortDigest ).
1827+ Build ()
1828+ d := NewDeployment ().
1829+ WithSelectorAndPodLabels (podLabel ).
1830+ WithPodSpec (ps ).
1831+ WithReplicas (utils .NewPtr (int32 (1 ))).
1832+ WithName ("test-deployment" ).
1833+ WithNamespace (ns .Name ).
1834+ Build ()
1835+ err = client .Create (ctx , d )
1836+ Expect (err ).NotTo (HaveOccurred ())
1837+ archLabelNSR := NewNodeSelectorRequirement ().
1838+ WithKeyAndValues (utils .ArchLabel , corev1 .NodeSelectorOpIn , utils .ArchitectureAmd64 ,
1839+ utils .ArchitectureArm64 , utils .ArchitectureS390x , utils .ArchitecturePpc64le ).
1840+ Build ()
1841+ expectedNSTs := NewNodeSelectorTerm ().WithMatchExpressions (archLabelNSR ).Build ()
1842+ By ("The pod should have been processed by the webhook and the scheduling gate label should be added" )
1843+ Eventually (framework .VerifyPodLabels (ctx , client , ns , "app" , "test" , e2e .Present , schedulingGateLabel ), e2e .WaitShort ).Should (Succeed ())
1844+ By ("Verify arch label are set" )
1845+ Eventually (framework .VerifyPodLabelsAreSet (ctx , client , ns , "app" , "test" ,
1846+ utils .MultiArchLabel , "" ,
1847+ utils .ArchLabelValue (utils .ArchitectureAmd64 ), "" ,
1848+ utils .ArchLabelValue (utils .ArchitectureArm64 ), "" ,
1849+ utils .ArchLabelValue (utils .ArchitectureS390x ), "" ,
1850+ utils .ArchLabelValue (utils .ArchitecturePpc64le ), "" ,
1851+ ), e2e .WaitShort ).Should (Succeed ())
1852+ By ("Verify node affinity label are set correct" )
1853+ Eventually (framework .VerifyPodLabelsAreSet (ctx , client , ns , "app" , "test" ,
1854+ utils .NodeAffinityLabel , utils .NodeAffinityLabelValueSet ,
1855+ utils .PreferredNodeAffinityLabel , utils .NodeAffinityLabelValueSet ,
1856+ ), e2e .WaitShort ).Should (Succeed ())
1857+ By ("The pod should get node affinity of arch info because the mirror registries are functional." )
1858+ Eventually (framework .VerifyPodNodeAffinity (ctx , client , ns , "app" , "test" , * expectedNSTs ), e2e .WaitShort ).Should (Succeed ())
1859+ By ("The pod should have the preferred affinities set in the ClusterPodPlacementConfig" )
1860+ Eventually (framework .VerifyPodPreferredNodeAffinity (ctx , client , ns , "app" , "test" ,
1861+ defaultExpectedAffinityTerms ()), e2e .WaitShort ).Should (Succeed ())
1862+ By ("The pod should be running" )
1863+ Eventually (framework .VerifyPodsAreRunning (ctx , client , ns , "app" , "test" ), e2e .WaitShort ).Should (Succeed ())
1864+ })
1865+ It ("Should set node affinity when image has tag and port" , func () {
1866+ var err error
1867+ By ("Create an ephemeral namespace" )
1868+ ns := framework .NewEphemeralNamespace ()
1869+ err = client .Create (ctx , ns )
1870+ Expect (err ).NotTo (HaveOccurred ())
1871+ //nolint:errcheck
1872+ defer client .Delete (ctx , ns )
1873+ By ("Create a deployment running image in source registry" )
1874+ ps := NewPodSpec ().
1875+ WithContainersImages (e2e .HelloopenshiftPublicMultiarchImageWithPortTag ).
1876+ Build ()
1877+ d := NewDeployment ().
1878+ WithSelectorAndPodLabels (podLabel ).
1879+ WithPodSpec (ps ).
1880+ WithReplicas (utils .NewPtr (int32 (1 ))).
1881+ WithName ("test-deployment" ).
1882+ WithNamespace (ns .Name ).
1883+ Build ()
1884+ err = client .Create (ctx , d )
1885+ Expect (err ).NotTo (HaveOccurred ())
1886+ archLabelNSR := NewNodeSelectorRequirement ().
1887+ WithKeyAndValues (utils .ArchLabel , corev1 .NodeSelectorOpIn , utils .ArchitectureAmd64 ,
1888+ utils .ArchitectureArm64 , utils .ArchitectureS390x , utils .ArchitecturePpc64le ).
1889+ Build ()
1890+ expectedNSTs := NewNodeSelectorTerm ().WithMatchExpressions (archLabelNSR ).Build ()
1891+ By ("The pod should have been processed by the webhook and the scheduling gate label should be added" )
1892+ Eventually (framework .VerifyPodLabels (ctx , client , ns , "app" , "test" , e2e .Present , schedulingGateLabel ), e2e .WaitShort ).Should (Succeed ())
1893+ By ("Verify arch label are set" )
1894+ Eventually (framework .VerifyPodLabelsAreSet (ctx , client , ns , "app" , "test" ,
1895+ utils .MultiArchLabel , "" ,
1896+ utils .ArchLabelValue (utils .ArchitectureAmd64 ), "" ,
1897+ utils .ArchLabelValue (utils .ArchitectureArm64 ), "" ,
1898+ utils .ArchLabelValue (utils .ArchitectureS390x ), "" ,
1899+ utils .ArchLabelValue (utils .ArchitecturePpc64le ), "" ,
1900+ ), e2e .WaitShort ).Should (Succeed ())
1901+ By ("Verify node affinity label are set correct" )
1902+ Eventually (framework .VerifyPodLabelsAreSet (ctx , client , ns , "app" , "test" ,
1903+ utils .NodeAffinityLabel , utils .NodeAffinityLabelValueSet ,
1904+ utils .PreferredNodeAffinityLabel , utils .NodeAffinityLabelValueSet ,
1905+ ), e2e .WaitShort ).Should (Succeed ())
1906+ By ("The pod should get node affinity of arch info because the mirror registries are functional." )
1907+ Eventually (framework .VerifyPodNodeAffinity (ctx , client , ns , "app" , "test" , * expectedNSTs ), e2e .WaitShort ).Should (Succeed ())
1908+ By ("The pod should have the preferred affinities set in the ClusterPodPlacementConfig" )
1909+ Eventually (framework .VerifyPodPreferredNodeAffinity (ctx , client , ns , "app" , "test" ,
1910+ defaultExpectedAffinityTerms ()), e2e .WaitShort ).Should (Succeed ())
1911+ By ("The pod should be running" )
1912+ Eventually (framework .VerifyPodsAreRunning (ctx , client , ns , "app" , "test" ), e2e .WaitShort ).Should (Succeed ())
1913+ })
1914+ It ("Should set node affinity when image has digest and tag and port" , func () {
1915+ var err error
1916+ By ("Create an ephemeral namespace" )
1917+ ns := framework .NewEphemeralNamespace ()
1918+ err = client .Create (ctx , ns )
1919+ Expect (err ).NotTo (HaveOccurred ())
1920+ //nolint:errcheck
1921+ defer client .Delete (ctx , ns )
1922+ By ("Create a deployment running image in source registry" )
1923+ ps := NewPodSpec ().
1924+ WithContainersImages (e2e .HelloopenshiftPublicMultiarchImageWithPortTagDigest ).
1925+ Build ()
1926+ d := NewDeployment ().
1927+ WithSelectorAndPodLabels (podLabel ).
1928+ WithPodSpec (ps ).
1929+ WithReplicas (utils .NewPtr (int32 (1 ))).
1930+ WithName ("test-deployment" ).
1931+ WithNamespace (ns .Name ).
1932+ Build ()
1933+ err = client .Create (ctx , d )
1934+ Expect (err ).NotTo (HaveOccurred ())
1935+ archLabelNSR := NewNodeSelectorRequirement ().
1936+ WithKeyAndValues (utils .ArchLabel , corev1 .NodeSelectorOpIn , utils .ArchitectureAmd64 ,
1937+ utils .ArchitectureArm64 , utils .ArchitectureS390x , utils .ArchitecturePpc64le ).
1938+ Build ()
1939+ expectedNSTs := NewNodeSelectorTerm ().WithMatchExpressions (archLabelNSR ).Build ()
1940+ By ("The pod should have been processed by the webhook and the scheduling gate label should be added" )
1941+ Eventually (framework .VerifyPodLabels (ctx , client , ns , "app" , "test" , e2e .Present , schedulingGateLabel ), e2e .WaitShort ).Should (Succeed ())
1942+ By ("Verify arch label are set" )
1943+ Eventually (framework .VerifyPodLabelsAreSet (ctx , client , ns , "app" , "test" ,
1944+ utils .MultiArchLabel , "" ,
1945+ utils .ArchLabelValue (utils .ArchitectureAmd64 ), "" ,
1946+ utils .ArchLabelValue (utils .ArchitectureArm64 ), "" ,
1947+ utils .ArchLabelValue (utils .ArchitectureS390x ), "" ,
1948+ utils .ArchLabelValue (utils .ArchitecturePpc64le ), "" ,
1949+ ), e2e .WaitShort ).Should (Succeed ())
1950+ By ("Verify node affinity label are set correct" )
1951+ Eventually (framework .VerifyPodLabelsAreSet (ctx , client , ns , "app" , "test" ,
1952+ utils .NodeAffinityLabel , utils .NodeAffinityLabelValueSet ,
1953+ utils .PreferredNodeAffinityLabel , utils .NodeAffinityLabelValueSet ,
1954+ ), e2e .WaitShort ).Should (Succeed ())
1955+ By ("The pod should get node affinity of arch info because the mirror registries are functional." )
1956+ Eventually (framework .VerifyPodNodeAffinity (ctx , client , ns , "app" , "test" , * expectedNSTs ), e2e .WaitShort ).Should (Succeed ())
1957+ By ("The pod should have the preferred affinities set in the ClusterPodPlacementConfig" )
1958+ Eventually (framework .VerifyPodPreferredNodeAffinity (ctx , client , ns , "app" , "test" ,
1959+ defaultExpectedAffinityTerms ()), e2e .WaitShort ).Should (Succeed ())
1960+ By ("The pod should be running" )
1961+ Eventually (framework .VerifyPodsAreRunning (ctx , client , ns , "app" , "test" ), e2e .WaitShort ).Should (Succeed ())
1962+ })
18161963 })
18171964})
0 commit comments