Skip to content

Commit 75b09b4

Browse files
committed
separete runOp
1 parent 486d12e commit 75b09b4

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

test/integration/scheduler_perf/scheduler_perf.go

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,30 +1526,9 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
15261526
return nil, fmt.Errorf("op %d: %v", opIndex, context.Cause(tCtx))
15271527
default:
15281528
}
1529-
switch concreteOp := realOp.(type) {
1530-
case *createNodesOp:
1531-
err = executor.runCreateNodesOp(opIndex, concreteOp)
1532-
case *createNamespacesOp:
1533-
err = executor.runCreateNamespaceOp(opIndex, concreteOp)
1534-
case *createPodsOp:
1535-
err = executor.runCreatePodsOp(opIndex, concreteOp)
1536-
case *deletePodsOp:
1537-
err = executor.runDeletePodsOp(opIndex, concreteOp)
1538-
case *churnOp:
1539-
err = executor.runChurnOp(opIndex, concreteOp)
1540-
case *barrierOp:
1541-
err = executor.runBarrierOp(opIndex, concreteOp)
1542-
case *sleepOp:
1543-
executor.runSleepOp(concreteOp)
1544-
case *startCollectingMetricsOp:
1545-
err = executor.runStartCollectingMetricsOp(opIndex, concreteOp)
1546-
case *stopCollectingMetricsOp:
1547-
err = executor.runStopCollectingMetrics(opIndex)
1548-
default:
1549-
err = executor.runDefaultOp(opIndex, concreteOp)
1550-
}
1529+
err = executor.runOp(realOp, opIndex)
15511530
if err != nil {
1552-
return nil, err
1531+
return nil, fmt.Errorf("op %d: %v", opIndex, err)
15531532
}
15541533
}
15551534

@@ -1564,6 +1543,31 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
15641543
return executor.dataItems, nil
15651544
}
15661545

1546+
func (e *WorkloadExecutor) runOp(op realOp, opIndex int) error {
1547+
switch concreteOp := op.(type) {
1548+
case *createNodesOp:
1549+
return e.runCreateNodesOp(opIndex, concreteOp)
1550+
case *createNamespacesOp:
1551+
return e.runCreateNamespaceOp(opIndex, concreteOp)
1552+
case *createPodsOp:
1553+
return e.runCreatePodsOp(opIndex, concreteOp)
1554+
case *deletePodsOp:
1555+
return e.runDeletePodsOp(opIndex, concreteOp)
1556+
case *churnOp:
1557+
return e.runChurnOp(opIndex, concreteOp)
1558+
case *barrierOp:
1559+
return e.runBarrierOp(opIndex, concreteOp)
1560+
case *sleepOp:
1561+
return e.runSleepOp(concreteOp)
1562+
case *startCollectingMetricsOp:
1563+
return e.runStartCollectingMetricsOp(opIndex, concreteOp)
1564+
case *stopCollectingMetricsOp:
1565+
return e.runStopCollectingMetrics(opIndex)
1566+
default:
1567+
return e.runDefaultOp(opIndex, concreteOp)
1568+
}
1569+
}
1570+
15671571
func (e *WorkloadExecutor) runCreateNodesOp(opIndex int, op *createNodesOp) error {
15681572
nodePreparer, err := getNodePreparer(fmt.Sprintf("node-%d-", opIndex), op, e.tCtx.Client())
15691573
if err != nil {
@@ -1629,11 +1633,12 @@ func (e *WorkloadExecutor) runBarrierOp(opIndex int, op *barrierOp) error {
16291633
return nil
16301634
}
16311635

1632-
func (e *WorkloadExecutor) runSleepOp(op *sleepOp) {
1636+
func (e *WorkloadExecutor) runSleepOp(op *sleepOp) error {
16331637
select {
16341638
case <-e.tCtx.Done():
16351639
case <-time.After(op.Duration.Duration):
16361640
}
1641+
return nil
16371642
}
16381643

16391644
func (e *WorkloadExecutor) runStopCollectingMetrics(opIndex int) error {

0 commit comments

Comments
 (0)