Skip to content

Commit 3d240f1

Browse files
AlinsRanCopilot
andcommitted
chore: remove unrelated framework changes from webhook validation PR
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f4047f6 commit 3d240f1

3 files changed

Lines changed: 13 additions & 88 deletions

File tree

test/e2e/framework/api7_dashboard.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,15 @@ import (
3333
)
3434

3535
var (
36-
valuesTemplate *template.Template
37-
_db string
38-
postgresImageRegistry string
39-
postgresImageRepository string
40-
postgresImageTag string
36+
valuesTemplate *template.Template
37+
_db string
4138
)
4239

4340
func init() {
4441
_db = os.Getenv("DB")
4542
if _db == "" {
4643
_db = postgres
4744
}
48-
49-
postgresImageRegistry = os.Getenv("POSTGRESQL_IMAGE_REGISTRY")
50-
postgresImageRepository = os.Getenv("POSTGRESQL_IMAGE_REPOSITORY")
51-
postgresImageTag = os.Getenv("POSTGRESQL_IMAGE_TAG")
52-
if postgresImageRegistry != "" && postgresImageRepository == "" {
53-
postgresImageRepository = "bitnami/postgresql"
54-
}
55-
5645
tmpl, err := template.New("values.yaml").Parse(`
5746
dashboard:
5847
image:
@@ -219,14 +208,6 @@ jaeger:
219208
postgresql:
220209
{{- if ne .DB "postgres" }}
221210
builtin: false
222-
{{- end }}
223-
{{- if .PostgresImageRegistry }}
224-
image:
225-
registry: {{ .PostgresImageRegistry }}
226-
repository: {{ .PostgresImageRepository }}
227-
{{- if .PostgresImageTag }}
228-
tag: {{ .PostgresImageTag }}
229-
{{- end }}
230211
{{- end }}
231212
primary:
232213
containerSecurityContext:

test/e2e/framework/api7_framework.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"helm.sh/helm/v3/pkg/cli"
3636
"helm.sh/helm/v3/pkg/kube"
3737
k8serrors "k8s.io/apimachinery/pkg/api/errors"
38-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3938
)
4039

4140
const defaultDashboardVersion = "dev"
@@ -78,10 +77,7 @@ func (f *Framework) BeforeSuite() {
7877
f.DeployComponents()
7978

8079
time.Sleep(1 * time.Minute)
81-
err := f.ensureServiceWithTimeout("api7ee3-dashboard", _namespace, 1, 300)
82-
Expect(err).ShouldNot(HaveOccurred(), "ensuring dashboard service")
83-
84-
err = f.newDashboardTunnel()
80+
err := f.newDashboardTunnel()
8581
f.Logf("Dashboard HTTP Tunnel:" + _dashboardHTTPTunnel.Endpoint())
8682
Expect(err).ShouldNot(HaveOccurred(), "creating dashboard tunnel")
8783

@@ -200,12 +196,9 @@ func (f *Framework) deploy() {
200196

201197
buf := bytes.NewBuffer(nil)
202198
_ = valuesTemplate.Execute(buf, map[string]any{
203-
"DB": _db,
204-
"DSN": getDSN(),
205-
"Tag": dashboardVersion,
206-
"PostgresImageRegistry": postgresImageRegistry,
207-
"PostgresImageRepository": postgresImageRepository,
208-
"PostgresImageTag": postgresImageTag,
199+
"DB": _db,
200+
"DSN": getDSN(),
201+
"Tag": dashboardVersion,
209202
})
210203

211204
f.Logf("values: %s", buf.String())
@@ -219,15 +212,10 @@ func (f *Framework) deploy() {
219212
}
220213
f.GomegaT.Expect(err).ShouldNot(HaveOccurred(), "install dashboard")
221214

222-
_, err = k8s.GetServiceE(GinkgoT(), f.kubectlOpts, "api7ee3-dashboard")
215+
err = f.ensureService("api7ee3-dashboard", _namespace, 1)
223216
f.GomegaT.Expect(err).ShouldNot(HaveOccurred(), "ensuring dashboard service")
224217

225-
err = WaitPodsAvailableWithTimeout(f.GinkgoT, f.kubectlOpts, metav1.ListOptions{
226-
LabelSelector: "app.kubernetes.io/instance=api7ee3,app.kubernetes.io/name=postgresql,app.kubernetes.io/component=primary",
227-
}, 5*time.Minute)
228-
f.GomegaT.Expect(err).ShouldNot(HaveOccurred(), "waiting for postgres pod ready")
229-
230-
err = f.ensureServiceWithTimeout("api7-postgresql", _namespace, 1, 300)
218+
err = f.ensureService("api7-postgresql", _namespace, 1)
231219
f.GomegaT.Expect(err).ShouldNot(HaveOccurred(), "ensuring postgres service")
232220
}
233221

test/e2e/framework/k8s.go

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,12 @@ func (f *Framework) applySSLSecret(namespace, name string, cert, pkey, caCert []
261261
}
262262

263263
func WaitPodsAvailable(t testing.TestingT, kubeOps *k8s.KubectlOptions, opts metav1.ListOptions) error {
264-
return WaitPodsAvailableWithTimeout(t, kubeOps, opts, 2*time.Minute)
265-
}
266-
267-
func WaitPodsAvailableWithTimeout(t testing.TestingT, kubeOps *k8s.KubectlOptions, opts metav1.ListOptions, timeout time.Duration) error {
268-
var lastErr error
269264
condFunc := func() (bool, error) {
270265
items, err := k8s.ListPodsE(t, kubeOps, opts)
271266
if err != nil {
272-
lastErr = err
273267
return false, err
274268
}
275269
if len(items) == 0 {
276-
lastErr = fmt.Errorf("no pods found for selector %q", opts.LabelSelector)
277270
return false, nil
278271
}
279272
for _, item := range items {
@@ -284,60 +277,23 @@ func WaitPodsAvailableWithTimeout(t testing.TestingT, kubeOps *k8s.KubectlOption
284277
}
285278
foundPodReady = true
286279
if cond.Status != "True" {
287-
lastErr = fmt.Errorf("pod %s is not ready: %s", item.Name, describePodStatus(item))
288280
return false, nil
289281
}
290282
}
291283
if !foundPodReady {
292-
lastErr = fmt.Errorf("pod %s has no Ready condition: %s", item.Name, describePodStatus(item))
293284
return false, nil
294285
}
295286
}
296287
return true, nil
297288
}
298-
err := waitConstantIntervalWithTimeout(condFunc, timeout)
299-
if err != nil && lastErr != nil {
300-
return lastErr
301-
}
302-
return err
303-
}
304-
305-
func describePodStatus(pod corev1.Pod) string {
306-
conditions := make([]string, 0, len(pod.Status.Conditions))
307-
for _, cond := range pod.Status.Conditions {
308-
conditions = append(conditions, fmt.Sprintf("%s=%s", cond.Type, cond.Status))
309-
}
310-
311-
containerStates := make([]string, 0, len(pod.Status.ContainerStatuses))
312-
for _, status := range pod.Status.ContainerStatuses {
313-
state := "unknown"
314-
switch {
315-
case status.State.Waiting != nil:
316-
state = fmt.Sprintf("waiting(%s:%s)", status.State.Waiting.Reason, status.State.Waiting.Message)
317-
case status.State.Terminated != nil:
318-
state = fmt.Sprintf("terminated(%s:%s)", status.State.Terminated.Reason, status.State.Terminated.Message)
319-
case status.State.Running != nil:
320-
state = "running"
321-
}
322-
containerStates = append(containerStates, fmt.Sprintf("%s=%s", status.Name, state))
323-
}
324-
325-
return fmt.Sprintf("phase=%s conditions=[%s] containers=[%s]",
326-
pod.Status.Phase,
327-
strings.Join(conditions, ", "),
328-
strings.Join(containerStates, ", "),
329-
)
289+
return waitExponentialBackoff(condFunc)
330290
}
331291

332-
func waitConstantIntervalWithTimeout(condFunc func() (bool, error), timeout time.Duration) error {
333-
steps := int(timeout / (2 * time.Second))
334-
if steps < 1 {
335-
steps = 1
336-
}
292+
func waitExponentialBackoff(condFunc func() (bool, error)) error {
337293
backoff := wait.Backoff{
338-
Duration: 2 * time.Second,
339-
Factor: 1,
340-
Steps: steps,
294+
Duration: 500 * time.Millisecond,
295+
Factor: 2,
296+
Steps: 8,
341297
}
342298
return wait.ExponentialBackoff(backoff, condFunc)
343299
}

0 commit comments

Comments
 (0)