@@ -1703,139 +1703,4 @@ var _ = Describe("KeycloakRealm controller", func() {
17031703 Expect (string (secret .Data ["realm.json" ])).Should (Equal (fmt .Sprintf (`{"realm":"%s","users":[{"username":"%s","enabled":true}],"components":null,"requiredActions":null}` , realm .Name , userName )))
17041704 })
17051705 })
1706- /*
1707- TODO: this test is flaky as the controller already progresses into another reconcile if the timeout occurs.
1708-
1709- When("a realm reconciler runs into spec.timeout", func() {
1710- realmName := fmt.Sprintf("realm-%s", rand.String(5))
1711-
1712- It("recreates the reconciler with a new secret", func() {
1713- By("creating a new KeycloakRealm")
1714- ctx := context.Background()
1715-
1716- authSecret := &corev1.Secret{
1717- ObjectMeta: metav1.ObjectMeta{
1718- Name: fmt.Sprintf("auth-%s", rand.String(5)),
1719- Namespace: "default",
1720- },
1721- StringData: map[string]string{
1722- "username": "kc-user",
1723- "password": "kc-password",
1724- },
1725- }
1726-
1727- Expect(k8sClient.Create(ctx, authSecret)).Should(Succeed())
1728-
1729- realm := &v1beta1.KeycloakRealm{
1730- ObjectMeta: metav1.ObjectMeta{
1731- Name: realmName,
1732- Namespace: "default",
1733- },
1734- Spec: v1beta1.KeycloakRealmSpec{
1735- Interval: &metav1.Duration{Duration: time.Second * 100},
1736- Timeout: &metav1.Duration{Duration: time.Second * 100},
1737- Version: "22.0.1",
1738- AuthSecret: v1beta1.SecretReference{
1739- Name: authSecret.Name,
1740- },
1741- },
1742- }
1743- Expect(k8sClient.Create(ctx, realm)).Should(Succeed())
1744-
1745- By("waiting for the reconciliation")
1746- instanceLookupKey := types.NamespacedName{Name: realmName, Namespace: "default"}
1747- reconciledInstance := &v1beta1.KeycloakRealm{}
1748-
1749- expectedStatus := &v1beta1.KeycloakRealmStatus{
1750- ObservedGeneration: 1,
1751- Conditions: []metav1.Condition{
1752- {
1753- Type: v1beta1.ConditionReady,
1754- Status: metav1.ConditionUnknown,
1755- Reason: "Progressing",
1756- Message: "Reconciliation in progress",
1757- },
1758- {
1759- Type: v1beta1.ConditionReconciling,
1760- Status: metav1.ConditionTrue,
1761- Reason: "Progressing",
1762- },
1763- },
1764- }
1765-
1766- Eventually(func() bool {
1767- err := k8sClient.Get(ctx, instanceLookupKey, reconciledInstance)
1768- if err != nil {
1769- return false
1770- }
1771-
1772- return needStatus(reconciledInstance, expectedStatus)
1773- }, timeout, interval).Should(BeTrue())
1774-
1775- })
1776-
1777- It("transitions into unready once the reconciler pod reached the timeout", func() {
1778- reconciledInstance := &v1beta1.KeycloakRealm{}
1779- instanceLookupKey := types.NamespacedName{Name: realmName, Namespace: "default"}
1780- Expect(k8sClient.Get(ctx, instanceLookupKey, reconciledInstance)).Should(Succeed())
1781-
1782- By("container shall be running for 500s")
1783- pod := &corev1.Pod{}
1784- Expect(k8sClient.Get(ctx, types.NamespacedName{
1785- Name: reconciledInstance.Status.Reconciler,
1786- Namespace: reconciledInstance.Namespace,
1787- }, pod)).Should(Succeed())
1788-
1789- pod.Status.ContainerStatuses = []corev1.ContainerStatus{
1790- {
1791- Name: "keycloak-config-cli",
1792- State: corev1.ContainerState{
1793- Running: &corev1.ContainerStateRunning{
1794- StartedAt: metav1.NewTime(time.Now().Add(time.Second * -500)),
1795- },
1796- },
1797- },
1798- }
1799-
1800- Expect(k8sClient.Status().Update(ctx, pod)).Should(Succeed())
1801-
1802- By("waiting for the reconciliation")
1803- expectedStatus := &v1beta1.KeycloakRealmStatus{
1804- ObservedGeneration: 1,
1805- Conditions: []metav1.Condition{
1806- {
1807- Type: v1beta1.ConditionReady,
1808- Status: metav1.ConditionFalse,
1809- Reason: "ReconciliationFailed",
1810- Message: "reconciler timeout reached",
1811- },
1812- },
1813- }
1814-
1815- Eventually(func() bool {
1816- err := k8sClient.Get(ctx, instanceLookupKey, reconciledInstance)
1817- if err != nil {
1818- return false
1819- }
1820-
1821- return needStatus(reconciledInstance, expectedStatus)
1822- }, timeout, interval).Should(BeTrue())
1823-
1824- By("making sure the reconciler pod is gone")
1825- Expect(k8sClient.Get(ctx, types.NamespacedName{
1826- Name: reconciledInstance.Status.Reconciler,
1827- Namespace: reconciledInstance.Namespace,
1828- }, pod)).Should(Not(BeNil()))
1829-
1830- Expect(reconciledInstance.Status.Reconciler).Should(Equal(""))
1831-
1832- By("making sure the realm secret is gone")
1833- var secret *corev1.Secret
1834- Expect(k8sClient.Get(ctx, types.NamespacedName{
1835- Name: reconciledInstance.Status.Reconciler,
1836- Namespace: reconciledInstance.Namespace,
1837- }, secret)).Should(Not(BeNil()))
1838- })
1839- })
1840- */
18411706})
0 commit comments