separete runOp

This commit is contained in:
YamasouA 2025-03-01 11:24:23 +09:00
parent 486d12efc5
commit 75b09b4054

View File

@ -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 {