@@ -1804,6 +1804,102 @@ var _ = Describe("OpenStackOperator controller", func() {
18041804 })
18051805 })
18061806
1807+ When ("An OpenStackControlplane instance is created with nodeSelector" , func () {
1808+ BeforeEach (func () {
1809+ spec := GetDefaultOpenStackControlPlaneSpec ()
1810+ spec ["tls" ] = GetTLSPublicSpec ()
1811+ nodeSelector := map [string ]string {
1812+ "foo" : "bar" ,
1813+ }
1814+ spec ["nodeSelector" ] = nodeSelector
1815+ DeferCleanup (
1816+ th .DeleteInstance ,
1817+ CreateOpenStackControlPlane (names .OpenStackControlplaneName , spec ),
1818+ )
1819+ })
1820+
1821+ It ("should set the galera nodeSelector" , func () {
1822+ Eventually (func (g Gomega ) {
1823+ db := mariadb .GetGalera (names .DBName )
1824+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo" : "bar" }))
1825+ }, timeout , interval ).Should (Succeed ())
1826+ Eventually (func (g Gomega ) {
1827+ db := mariadb .GetGalera (names .DBCell1Name )
1828+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo" : "bar" }))
1829+ }, timeout , interval ).Should (Succeed ())
1830+ })
1831+
1832+ It ("should update the galera nodeSelector" , func () {
1833+ Eventually (func (g Gomega ) {
1834+ db := mariadb .GetGalera (names .DBName )
1835+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo" : "bar" }))
1836+ }, timeout , interval ).Should (Succeed ())
1837+ Eventually (func (g Gomega ) {
1838+ db := mariadb .GetGalera (names .DBCell1Name )
1839+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo" : "bar" }))
1840+ }, timeout , interval ).Should (Succeed ())
1841+
1842+ Eventually (func (g Gomega ) {
1843+ OSCtlplane := GetOpenStackControlPlane (names .OpenStackControlplaneName )
1844+ newNodeSelector := map [string ]string {
1845+ "foo2" : "bar2" ,
1846+ }
1847+ OSCtlplane .Spec .NodeSelector = newNodeSelector
1848+ g .Expect (k8sClient .Update (ctx , OSCtlplane )).Should (Succeed ())
1849+ }, timeout , interval ).Should (Succeed ())
1850+
1851+ Eventually (func (g Gomega ) {
1852+ db := mariadb .GetGalera (names .DBName )
1853+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo2" : "bar2" }))
1854+ }, timeout , interval ).Should (Succeed ())
1855+ Eventually (func (g Gomega ) {
1856+ db := mariadb .GetGalera (names .DBCell1Name )
1857+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo2" : "bar2" }))
1858+ }, timeout , interval ).Should (Succeed ())
1859+ })
1860+
1861+ It ("should allow the galera nodeSelector to be overridden" , func () {
1862+ Eventually (func (g Gomega ) {
1863+ db := mariadb .GetGalera (names .DBName )
1864+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo" : "bar" }))
1865+ }, timeout , interval ).Should (Succeed ())
1866+ Eventually (func (g Gomega ) {
1867+ db := mariadb .GetGalera (names .DBCell1Name )
1868+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo" : "bar" }))
1869+ }, timeout , interval ).Should (Succeed ())
1870+
1871+ Eventually (func (g Gomega ) {
1872+ OSCtlplane := GetOpenStackControlPlane (names .OpenStackControlplaneName )
1873+
1874+ newNodeSelector := map [string ]string {
1875+ "foo2" : "bar2" ,
1876+ }
1877+ galeraTemplates := * (OSCtlplane .Spec .Galera .Templates )
1878+ dbTemplate := galeraTemplates [names .DBName .Name ]
1879+ dbTemplate .NodeSelector = & newNodeSelector
1880+ galeraTemplates [names .DBName .Name ] = dbTemplate
1881+
1882+ emptyNodeSelector := map [string ]string {}
1883+ cell1Template := galeraTemplates [names .DBCell1Name .Name ]
1884+ cell1Template .NodeSelector = & emptyNodeSelector
1885+ galeraTemplates [names .DBCell1Name .Name ] = cell1Template
1886+
1887+ OSCtlplane .Spec .Galera .Templates = & galeraTemplates
1888+
1889+ g .Expect (k8sClient .Update (ctx , OSCtlplane )).Should (Succeed ())
1890+ }, timeout , interval ).Should (Succeed ())
1891+
1892+ Eventually (func (g Gomega ) {
1893+ db := mariadb .GetGalera (names .DBName )
1894+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {"foo2" : "bar2" }))
1895+ }, timeout , interval ).Should (Succeed ())
1896+ Eventually (func (g Gomega ) {
1897+ db := mariadb .GetGalera (names .DBCell1Name )
1898+ g .Expect (* db .Spec .NodeSelector ).To (Equal (map [string ]string {}))
1899+ }, timeout , interval ).Should (Succeed ())
1900+ })
1901+ })
1902+
18071903})
18081904
18091905var _ = Describe ("OpenStackOperator Webhook" , func () {
0 commit comments