Skip to content

Commit

Permalink
chore: remove useless test
Browse files Browse the repository at this point in the history
  • Loading branch information
earayu committed Dec 19, 2024
1 parent b94a9c0 commit 8e81580
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 42 deletions.
1 change: 1 addition & 0 deletions endtoend/framework/onlineddl_utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package framework
Empty file.
43 changes: 43 additions & 0 deletions endtoend/onlineddl/scheduler/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package scheduler

import (
_ "embed"
"flag"
"github.com/wesql/wescale/endtoend/framework/clusters"
"log"
"os"
"testing"
)

var dbName = "onlineddl_scheduler_e2e_test"

//go:embed setup.sql
var setupSql string

//go:embed cleanup.sql
var cleanupSql string

var cluster *clusters.SingleNodeCluster

func TestMain(m *testing.M) {
cluster = clusters.NewDefaultSingleNodeCluster()
cluster.RegisterFlagsForSingleNodeCluster()
flag.Parse()

// Setup the test environment
err := cluster.SetUp(dbName, setupSql)
if err != nil {
log.Fatalf("Setup failed: %v", err)
}

// Run the tests
code := m.Run()

// Cleanup the test environment
err = cluster.CleanUp(cleanupSql)
if err != nil {
log.Fatalf("Cleanup failed: %v", err)
}

os.Exit(code)
}
1 change: 1 addition & 0 deletions endtoend/onlineddl/scheduler/onlineddl_scheduler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package scheduler
Empty file.
59 changes: 17 additions & 42 deletions go/test/endtoend/onlineddl/scheduler/onlineddl_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const (
type testOnlineDDLStatementParams struct {
ddlStatement string
ddlStrategy string
executeStrategy string
expectHint string
expectError string
skipWait bool
Expand Down Expand Up @@ -308,12 +307,11 @@ func testPause(t *testing.T) {

createParams := func(ddlStatement string, ddlStrategy string, executeStrategy string, expectHint string, expectError string, skipWait bool) *testOnlineDDLStatementParams {
return &testOnlineDDLStatementParams{
ddlStatement: ddlStatement,
ddlStrategy: ddlStrategy,
executeStrategy: executeStrategy,
expectHint: expectHint,
expectError: expectError,
skipWait: skipWait,
ddlStatement: ddlStatement,
ddlStrategy: ddlStrategy,
expectHint: expectHint,
expectError: expectError,
skipWait: skipWait,
}
}

Expand Down Expand Up @@ -693,12 +691,11 @@ func testScheduler(t *testing.T) {

createParams := func(ddlStatement string, ddlStrategy string, executeStrategy string, expectHint string, expectError string, skipWait bool) *testOnlineDDLStatementParams {
return &testOnlineDDLStatementParams{
ddlStatement: ddlStatement,
ddlStrategy: ddlStrategy,
executeStrategy: executeStrategy,
expectHint: expectHint,
expectError: expectError,
skipWait: skipWait,
ddlStatement: ddlStatement,
ddlStrategy: ddlStrategy,
expectHint: expectHint,
expectError: expectError,
skipWait: skipWait,
}
}

Expand Down Expand Up @@ -1234,37 +1231,15 @@ func testOnlineDDLStatement(t *testing.T, params *testOnlineDDLStatementParams)

tableName := parseTableName(t, params.ddlStatement)

if params.executeStrategy == "vtgate" {
require.Empty(t, params.migrationContext, "explicit migration context not supported in vtgate. Test via vtctl")
result := onlineddl.VtgateExecDDL(t, &vtParams, params.ddlStrategy, params.ddlStatement, params.expectError)
if result != nil {
row := result.Named().Row()
if row != nil {
uuid = row.AsString("uuid", "")
}
}
} else {
vtctlParams := &cluster.VtctlClientParams{DDLStrategy: params.ddlStrategy, MigrationContext: params.migrationContext, SkipPreflight: true}
if overrideVtctlParams != nil {
vtctlParams = overrideVtctlParams
}
output, err := clusterInstance.VtctlclientProcess.ApplySchemaWithOutput(keyspaceName, params.ddlStatement, *vtctlParams)
switch params.expectError {
case anyErrorIndicator:
if err != nil {
// fine. We got any error.
t.Logf("expected any error, got this error: %v", err)
return
}
uuid = output
case "":
assert.NoError(t, err)
uuid = output
default:
assert.Error(t, err)
assert.Contains(t, output, params.expectError)
require.Empty(t, params.migrationContext, "explicit migration context not supported in vtgate. Test via vtctl")
result := onlineddl.VtgateExecDDL(t, &vtParams, params.ddlStrategy, params.ddlStatement, params.expectError)
if result != nil {
row := result.Named().Row()
if row != nil {
uuid = row.AsString("uuid", "")
}
}

uuid = strings.TrimSpace(uuid)
fmt.Println("# Generated UUID (for debug purposes):")
fmt.Printf("<%s>\n", uuid)
Expand Down

0 comments on commit 8e81580

Please sign in to comment.