@@ -49,9 +49,10 @@ import (
49
49
)
50
50
51
51
var (
52
- factory * fixtures.Factory
53
- fdbCluster * fixtures.FdbCluster
54
- testOptions * fixtures.FactoryOptions
52
+ factory * fixtures.Factory
53
+ fdbCluster * fixtures.FdbCluster
54
+ testOptions * fixtures.FactoryOptions
55
+ scheduleInjectPodKill * fixtures.ChaosMeshExperiment
55
56
)
56
57
57
58
func init () {
@@ -81,7 +82,7 @@ var _ = BeforeSuite(func() {
81
82
82
83
// In order to test the robustness of the operator we try to kill the operator Pods every minute.
83
84
if factory .ChaosTestsEnabled () {
84
- factory .ScheduleInjectPodKill (
85
+ scheduleInjectPodKill = factory .ScheduleInjectPodKill (
85
86
fixtures .GetOperatorSelector (fdbCluster .Namespace ()),
86
87
"*/2 * * * *" ,
87
88
chaosmesh .OneMode ,
@@ -1893,4 +1894,86 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
1893
1894
})
1894
1895
})
1895
1896
})
1897
+
1898
+ When ("the cluster makes use of DNS in the cluster file" , func () {
1899
+ var initialSetting bool
1900
+
1901
+ BeforeEach (func () {
1902
+ // Until the race condition is resolved in the FDB go bindings make sure the operator is not restarted.
1903
+ factory .DeleteChaosMeshExperimentSafe (scheduleInjectPodKill )
1904
+ cluster := fdbCluster .GetCluster ()
1905
+ parsedVersion , err := fdbv1beta2 .ParseFdbVersion (cluster .Status .RunningVersion )
1906
+ Expect (err ).NotTo (HaveOccurred ())
1907
+
1908
+ if ! parsedVersion .SupportsDNSInClusterFile () {
1909
+ Skip (fmt .Sprintf ("current FoundationDB version %s doesn't support DNS" , parsedVersion .String ()))
1910
+ }
1911
+
1912
+ initialSetting = cluster .UseDNSInClusterFile ()
1913
+ if ! cluster .UseDNSInClusterFile () {
1914
+ Expect (fdbCluster .SetUseDNSInClusterFile (true )).ToNot (HaveOccurred ())
1915
+ }
1916
+ })
1917
+
1918
+ AfterEach (func () {
1919
+ Expect (fdbCluster .SetUseDNSInClusterFile (initialSetting )).ToNot (HaveOccurred ())
1920
+
1921
+ if factory .ChaosTestsEnabled () {
1922
+ scheduleInjectPodKill = factory .ScheduleInjectPodKill (
1923
+ fixtures .GetOperatorSelector (fdbCluster .Namespace ()),
1924
+ "*/2 * * * *" ,
1925
+ chaosmesh .OneMode ,
1926
+ )
1927
+ }
1928
+ })
1929
+
1930
+ When ("all Pods are deleted" , func () {
1931
+ var initialPodsCnt int
1932
+ var initialReplaceTime time.Duration
1933
+
1934
+ BeforeEach (func () {
1935
+ availabilityCheck = false
1936
+ initialReplaceTime = time .Duration (pointer .IntDeref (
1937
+ fdbCluster .GetClusterSpec ().AutomationOptions .Replacements .FailureDetectionTimeSeconds ,
1938
+ 90 ,
1939
+ )) * time .Second
1940
+ Expect (fdbCluster .SetAutoReplacements (false , 30 * time .Hour )).ShouldNot (HaveOccurred ())
1941
+ // Make sure the operator is not taking any action to prevent any race condition.
1942
+ Expect (fdbCluster .SetSkipReconciliation (true )).NotTo (HaveOccurred ())
1943
+
1944
+ // Delete all Pods
1945
+ pods := fdbCluster .GetPods ()
1946
+ initialPodsCnt = len (pods .Items )
1947
+ for _ , pod := range pods .Items {
1948
+ podToDelete := & pod
1949
+ factory .Delete (podToDelete )
1950
+ }
1951
+
1952
+ // Make sure the Pods are all deleted.
1953
+ Eventually (func () []corev1.Pod {
1954
+ return fdbCluster .GetPods ().Items
1955
+ }).WithTimeout (5 * time .Minute ).WithPolling (2 * time .Second ).Should (BeEmpty ())
1956
+
1957
+ // Enable the operator again
1958
+ Expect (fdbCluster .SetSkipReconciliation (false )).NotTo (HaveOccurred ())
1959
+ })
1960
+
1961
+ It ("should recreate all Pods and bring the cluster into a healthy state again" , func () {
1962
+ Eventually (func () int {
1963
+ return len (fdbCluster .GetPods ().Items )
1964
+ }).WithTimeout (5 * time .Minute ).WithPolling (2 * time .Second ).Should (BeNumerically (">=" , initialPodsCnt ))
1965
+
1966
+ Eventually (func () bool {
1967
+ return fdbCluster .GetStatus ().Client .DatabaseStatus .Available
1968
+ }).WithTimeout (5 * time .Minute ).WithPolling (2 * time .Second ).Should (BeTrue ())
1969
+
1970
+ Expect (fdbCluster .WaitForReconciliation ()).NotTo (HaveOccurred ())
1971
+ })
1972
+
1973
+ AfterEach (func () {
1974
+ Expect (fdbCluster .SetSkipReconciliation (false )).NotTo (HaveOccurred ())
1975
+ Expect (fdbCluster .SetAutoReplacements (true , initialReplaceTime )).ShouldNot (HaveOccurred ())
1976
+ })
1977
+ })
1978
+ })
1896
1979
})
0 commit comments