@@ -1481,6 +1481,38 @@ func TestSolveOperators_WithSkips(t *testing.T) {
1481
1481
require .EqualValues (t , expected , operators )
1482
1482
}
1483
1483
1484
+ func TestSolveOperatorsWithSkipsPreventingSelection (t * testing.T ) {
1485
+ const namespace = "test-namespace"
1486
+ catalog := registry.CatalogKey {Name : "test-catalog" , Namespace : namespace }
1487
+ gvks := APISet {opregistry.APIKey {Group : "g" , Version : "v" , Kind : "k" , Plural : "ks" }: struct {}{}}
1488
+
1489
+ // Subscription candidate a-1 requires a GVK provided
1490
+ // exclusively by b-1, but b-1 is skipped by b-3 and can't be
1491
+ // chosen.
1492
+ subs := []* v1alpha1.Subscription {newSub (namespace , "a" , "channel" , catalog )}
1493
+ a1 := genOperator ("a-1" , "1.0.0" , "" , "a" , "channel" , catalog .Name , catalog .Namespace , gvks , nil , nil , "" , false )
1494
+ b3 := genOperator ("b-3" , "3.0.0" , "b-2" , "b" , "channel" , catalog .Name , catalog .Namespace , nil , nil , nil , "" , false )
1495
+ b3 .skips = []string {"b-1" }
1496
+ b2 := genOperator ("b-2" , "2.0.0" , "b-1" , "b" , "channel" , catalog .Name , catalog .Namespace , nil , nil , nil , "" , false )
1497
+ b1 := genOperator ("b-1" , "1.0.0" , "" , "b" , "channel" , catalog .Name , catalog .Namespace , nil , gvks , nil , "" , false )
1498
+
1499
+ logger , _ := test .NewNullLogger ()
1500
+ satResolver := SatResolver {
1501
+ cache : getFakeOperatorCache (NamespacedOperatorCache {
1502
+ snapshots : map [registry.CatalogKey ]* CatalogSnapshot {
1503
+ catalog : {
1504
+ key : catalog ,
1505
+ operators : []* Operator {a1 , b3 , b2 , b1 },
1506
+ },
1507
+ },
1508
+ }),
1509
+ log : logger ,
1510
+ }
1511
+
1512
+ _ , err := satResolver .SolveOperators ([]string {namespace }, nil , subs )
1513
+ assert .IsType (t , solver.NotSatisfiable {}, err )
1514
+ }
1515
+
1484
1516
func TestSolveOperatorsWithClusterServiceVersionHavingDependency (t * testing.T ) {
1485
1517
const namespace = "test-namespace"
1486
1518
catalog := registry.CatalogKey {Name : "test-catalog" , Namespace : namespace }
@@ -1824,6 +1856,54 @@ func TestSortChannel(t *testing.T) {
1824
1856
},
1825
1857
Err : errors .New (`a cycle exists in the chain of replacement beginning with "a" in channel "channel" of package "package"` ),
1826
1858
},
1859
+ {
1860
+ Name : "skipped and replaced entry omitted" ,
1861
+ In : []* Operator {
1862
+ {
1863
+ name : "a" ,
1864
+ replaces : "b" ,
1865
+ skips : []string {"b" },
1866
+ },
1867
+ {
1868
+ name : "b" ,
1869
+ },
1870
+ },
1871
+ Out : []* Operator {
1872
+ {
1873
+ name : "a" ,
1874
+ replaces : "b" ,
1875
+ skips : []string {"b" },
1876
+ },
1877
+ },
1878
+ },
1879
+ {
1880
+ Name : "skipped entry omitted" ,
1881
+ In : []* Operator {
1882
+ {
1883
+ name : "a" ,
1884
+ replaces : "b" ,
1885
+ skips : []string {"c" },
1886
+ },
1887
+ {
1888
+ name : "b" ,
1889
+ replaces : "c" ,
1890
+ },
1891
+ {
1892
+ name : "c" ,
1893
+ },
1894
+ },
1895
+ Out : []* Operator {
1896
+ {
1897
+ name : "a" ,
1898
+ replaces : "b" ,
1899
+ skips : []string {"c" },
1900
+ },
1901
+ {
1902
+ name : "b" ,
1903
+ replaces : "c" ,
1904
+ },
1905
+ },
1906
+ },
1827
1907
{
1828
1908
Name : "two replaces chains" ,
1829
1909
In : []* Operator {
0 commit comments