Skip to content

Commit

Permalink
Test: Take test host/runner specs into account for VDiff diff duratio…
Browse files Browse the repository at this point in the history
…n test (#14868)

Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord authored Dec 28, 2023
1 parent 47de203 commit e5b7def
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion go/test/endtoend/vreplication/vdiff2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package vreplication

import (
"fmt"
"math"
"runtime"
"strings"
"testing"
"time"
Expand All @@ -29,6 +31,7 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vttablet"

Expand Down Expand Up @@ -214,8 +217,13 @@ func testWorkflow(t *testing.T, vc *VitessCluster, tc *testCase, tks *Keyspace,
require.NoError(t, err, "could not parse --max-diff-duration %q: %v", diffDuration, err)
seconds := int64(dur.Seconds())
chunkSize := int64(100000)
perSecondCount := int64(1000000)
// Take the test host/runner vCPU count into account when generating rows.
perVCpuCount := int64(100000)
// Cap it at 1M rows per second so that we will create betweeen 100,000 and 1,000,000
// rows for each second in the diff duration, depending on the test host vCPU count.
perSecondCount := int64(math.Min(float64(perVCpuCount*int64(runtime.NumCPU())), 1000000))
totalRowsToCreate := seconds * perSecondCount
log.Infof("Test host has %d vCPUs. Generating %d rows in the customer table to test --max-diff-duration", runtime.NumCPU(), totalRowsToCreate)
for i := int64(0); i < totalRowsToCreate; i += chunkSize {
generateMoreCustomers(t, sourceKs, chunkSize)
}
Expand Down

0 comments on commit e5b7def

Please sign in to comment.