From 75b09b405405abaa5035c3a34dbba12417fe0415 Mon Sep 17 00:00:00 2001 From: YamasouA Date: Sat, 1 Mar 2025 11:24:23 +0900 Subject: [PATCH] separete runOp --- .../scheduler_perf/scheduler_perf.go | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/test/integration/scheduler_perf/scheduler_perf.go b/test/integration/scheduler_perf/scheduler_perf.go index 1cc7f7d752a..bca71f9b061 100644 --- a/test/integration/scheduler_perf/scheduler_perf.go +++ b/test/integration/scheduler_perf/scheduler_perf.go @@ -1526,30 +1526,9 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact return nil, fmt.Errorf("op %d: %v", opIndex, context.Cause(tCtx)) default: } - switch concreteOp := realOp.(type) { - case *createNodesOp: - err = executor.runCreateNodesOp(opIndex, concreteOp) - case *createNamespacesOp: - err = executor.runCreateNamespaceOp(opIndex, concreteOp) - case *createPodsOp: - err = executor.runCreatePodsOp(opIndex, concreteOp) - case *deletePodsOp: - err = executor.runDeletePodsOp(opIndex, concreteOp) - case *churnOp: - err = executor.runChurnOp(opIndex, concreteOp) - case *barrierOp: - err = executor.runBarrierOp(opIndex, concreteOp) - case *sleepOp: - executor.runSleepOp(concreteOp) - case *startCollectingMetricsOp: - err = executor.runStartCollectingMetricsOp(opIndex, concreteOp) - case *stopCollectingMetricsOp: - err = executor.runStopCollectingMetrics(opIndex) - default: - err = executor.runDefaultOp(opIndex, concreteOp) - } + err = executor.runOp(realOp, opIndex) if err != nil { - return nil, err + return nil, fmt.Errorf("op %d: %v", opIndex, err) } } @@ -1564,6 +1543,31 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact return executor.dataItems, nil } +func (e *WorkloadExecutor) runOp(op realOp, opIndex int) error { + switch concreteOp := op.(type) { + case *createNodesOp: + return e.runCreateNodesOp(opIndex, concreteOp) + case *createNamespacesOp: + return e.runCreateNamespaceOp(opIndex, concreteOp) + case *createPodsOp: + return e.runCreatePodsOp(opIndex, concreteOp) + case *deletePodsOp: + return e.runDeletePodsOp(opIndex, concreteOp) + case *churnOp: + return e.runChurnOp(opIndex, concreteOp) + case *barrierOp: + return e.runBarrierOp(opIndex, concreteOp) + case *sleepOp: + return e.runSleepOp(concreteOp) + case *startCollectingMetricsOp: + return e.runStartCollectingMetricsOp(opIndex, concreteOp) + case *stopCollectingMetricsOp: + return e.runStopCollectingMetrics(opIndex) + default: + return e.runDefaultOp(opIndex, concreteOp) + } +} + func (e *WorkloadExecutor) runCreateNodesOp(opIndex int, op *createNodesOp) error { nodePreparer, err := getNodePreparer(fmt.Sprintf("node-%d-", opIndex), op, e.tCtx.Client()) if err != nil { @@ -1629,11 +1633,12 @@ func (e *WorkloadExecutor) runBarrierOp(opIndex int, op *barrierOp) error { return nil } -func (e *WorkloadExecutor) runSleepOp(op *sleepOp) { +func (e *WorkloadExecutor) runSleepOp(op *sleepOp) error { select { case <-e.tCtx.Done(): case <-time.After(op.Duration.Duration): } + return nil } func (e *WorkloadExecutor) runStopCollectingMetrics(opIndex int) error {