@@ -1543,6 +1543,9 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
1543
1543
}
1544
1544
return obtainedPodNames
1545
1545
}, ConsistOf (tc .expectedPods )))
1546
+ for _ , pod := range obtainedStructuredPodList .Items {
1547
+ Expect (informer .Get (context .Background (), client .ObjectKeyFromObject (& pod ), & pod )).To (Succeed ()) //nolint:gosec // We don't retain the pointer
1548
+ }
1546
1549
1547
1550
By ("Checking with unstructured" )
1548
1551
obtainedUnstructuredPodList := unstructured.UnstructuredList {}
@@ -1560,6 +1563,9 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
1560
1563
}
1561
1564
return obtainedPodNames
1562
1565
}, ConsistOf (tc .expectedPods )))
1566
+ for _ , pod := range obtainedUnstructuredPodList .Items {
1567
+ Expect (informer .Get (context .Background (), client .ObjectKeyFromObject (& pod ), & pod )).To (Succeed ()) //nolint:gosec // We don't retain the pointer
1568
+ }
1563
1569
1564
1570
By ("Checking with metadata" )
1565
1571
obtainedMetadataPodList := metav1.PartialObjectMetadataList {}
@@ -1577,6 +1583,9 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
1577
1583
}
1578
1584
return obtainedPodNames
1579
1585
}, ConsistOf (tc .expectedPods )))
1586
+ for _ , pod := range obtainedMetadataPodList .Items {
1587
+ Expect (informer .Get (context .Background (), client .ObjectKeyFromObject (& pod ), & pod )).To (Succeed ()) //nolint:gosec // We don't retain the pointer
1588
+ }
1580
1589
},
1581
1590
Entry ("when selectors are empty it has to inform about all the pods" , selectorsTestCase {
1582
1591
expectedPods : []string {"test-pod-1" , "test-pod-2" , "test-pod-3" , "test-pod-4" , "test-pod-5" , "test-pod-6" },
@@ -1789,6 +1798,54 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
1789
1798
},
1790
1799
expectedPods : []string {},
1791
1800
}),
1801
+ Entry ("Only NamespaceAll in DefaultNamespaces returns all pods" , selectorsTestCase {
1802
+ options : cache.Options {
1803
+ DefaultNamespaces : map [string ]cache.Config {
1804
+ metav1 .NamespaceAll : {},
1805
+ },
1806
+ },
1807
+ expectedPods : []string {"test-pod-1" , "test-pod-2" , "test-pod-3" , "test-pod-4" , "test-pod-5" , "test-pod-6" },
1808
+ }),
1809
+ Entry ("Only NamespaceAll in ByObject.Namespaces returns all pods" , selectorsTestCase {
1810
+ options : cache.Options {
1811
+ ByObject : map [client.Object ]cache.ByObject {
1812
+ & corev1.Pod {}: {
1813
+ Namespaces : map [string ]cache.Config {
1814
+ metav1 .NamespaceAll : {},
1815
+ },
1816
+ },
1817
+ },
1818
+ },
1819
+ expectedPods : []string {"test-pod-1" , "test-pod-2" , "test-pod-3" , "test-pod-4" , "test-pod-5" , "test-pod-6" },
1820
+ }),
1821
+ Entry ("NamespaceAll in DefaultNamespaces creates a cache for all Namespaces that are not in DefaultNamespaces" , selectorsTestCase {
1822
+ options : cache.Options {
1823
+ DefaultNamespaces : map [string ]cache.Config {
1824
+ metav1 .NamespaceAll : {},
1825
+ testNamespaceOne : {
1826
+ // labels.Nothing when serialized matches everything, so we have to construct our own "match nothing" selector
1827
+ LabelSelector : labels .SelectorFromSet (labels.Set {"no-present" : "not-present" })},
1828
+ },
1829
+ },
1830
+ // All pods that are not in NamespaceOne
1831
+ expectedPods : []string {"test-pod-2" , "test-pod-3" , "test-pod-4" , "test-pod-6" },
1832
+ }),
1833
+ Entry ("NamespaceAll in ByObject.Namespaces creates a cache for all Namespaces that are not in ByObject.Namespaces" , selectorsTestCase {
1834
+ options : cache.Options {
1835
+ ByObject : map [client.Object ]cache.ByObject {
1836
+ & corev1.Pod {}: {
1837
+ Namespaces : map [string ]cache.Config {
1838
+ metav1 .NamespaceAll : {},
1839
+ testNamespaceOne : {
1840
+ // labels.Nothing when serialized matches everything, so we have to construct our own "match nothing" selector
1841
+ LabelSelector : labels .SelectorFromSet (labels.Set {"no-present" : "not-present" })},
1842
+ },
1843
+ },
1844
+ },
1845
+ },
1846
+ // All pods that are not in NamespaceOne
1847
+ expectedPods : []string {"test-pod-2" , "test-pod-3" , "test-pod-4" , "test-pod-6" },
1848
+ }),
1792
1849
)
1793
1850
})
1794
1851
Describe ("as an Informer" , func () {
0 commit comments