-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*added preselect affordable mutate, check and ddl functions from table conditions.
- Loading branch information
1 parent
cfbf0fd
commit 157cc86
Showing
11 changed files
with
477 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2019 ScyllaDB | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//nolint:thelper | ||
package jobs | ||
|
||
import "github.com/scylladb/gemini/pkg/testschema" | ||
|
||
func UpdateAllCases(table *testschema.Table) testschema.Functions { | ||
return testschema.Functions{ | ||
Check: testschema.UpdateFuncCases(table, GenCheckStmtConditions, GenCheckStmtRatios), | ||
Mutate: testschema.UpdateFuncCases(table, GenMutateStmtConditions, GenMutateStmtRatios), | ||
DDL: testschema.UpdateFuncCases(table, GenDdlStmtConditions, GenDdlStmtRatios), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// Copyright 2019 ScyllaDB | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//nolint:thelper | ||
package jobs | ||
|
||
import ( | ||
"testing" | ||
|
||
"golang.org/x/exp/rand" | ||
|
||
"github.com/scylladb/gemini/pkg/coltypes" | ||
"github.com/scylladb/gemini/pkg/testschema" | ||
"github.com/scylladb/gemini/pkg/typedef" | ||
) | ||
|
||
var genCheckfullCases = []int{ | ||
GenSinglePartitionID, | ||
GenSinglePartitionMvID, | ||
GenMultiplePartitionID, | ||
GenMultiplePartitionMvID, | ||
GenClusteringRangeID, | ||
GenClusteringRangeMvID, | ||
GenMultiplePartitionClusteringRangeID, | ||
GenMultiplePartitionClusteringRangeMvID, | ||
GenSingleIndexQueryID, | ||
} | ||
|
||
var genCheckNoIndex = []int{ | ||
GenSinglePartitionID, | ||
GenSinglePartitionMvID, | ||
GenMultiplePartitionID, | ||
GenMultiplePartitionMvID, | ||
GenClusteringRangeID, | ||
GenClusteringRangeMvID, | ||
GenMultiplePartitionClusteringRangeID, | ||
GenMultiplePartitionClusteringRangeMvID, | ||
} | ||
|
||
var genCheckNoMV = []int{ | ||
GenSinglePartitionID, | ||
GenMultiplePartitionID, | ||
GenClusteringRangeID, | ||
GenMultiplePartitionClusteringRangeID, | ||
GenSingleIndexQueryID, | ||
} | ||
|
||
var genCheckNoClustering = []int{ | ||
GenSinglePartitionID, | ||
GenSinglePartitionMvID, | ||
GenMultiplePartitionID, | ||
GenMultiplePartitionMvID, | ||
GenSingleIndexQueryID, | ||
} | ||
|
||
var genCheckMin = []int{ | ||
GenSinglePartitionID, | ||
GenMultiplePartitionID, | ||
} | ||
|
||
type comparer struct { | ||
expected []int | ||
received testschema.CasesInfo | ||
} | ||
|
||
func TestGetFuncCases(t *testing.T) { | ||
tableFull := getTestTable() | ||
|
||
tableNoIndexes := getTestTable() | ||
tableNoIndexes.Indexes = nil | ||
|
||
tableNoMV := getTestTable() | ||
tableNoMV.MaterializedViews = nil | ||
|
||
tableNoClustering := getTestTable() | ||
tableNoClustering.ClusteringKeys = nil | ||
|
||
tableMin := getTestTable() | ||
tableMin.Indexes = nil | ||
tableMin.MaterializedViews = nil | ||
tableMin.ClusteringKeys = nil | ||
|
||
genCheckList := map[string]comparer{ | ||
"genCheck_fullCases": {received: testschema.UpdateFuncCases(&tableFull, GenCheckStmtConditions, GenCheckStmtRatios), expected: genCheckfullCases}, | ||
"genCheck_NoIndex": {received: testschema.UpdateFuncCases(&tableNoIndexes, GenCheckStmtConditions, GenCheckStmtRatios), expected: genCheckNoIndex}, | ||
"genCheck_NoMV": {received: testschema.UpdateFuncCases(&tableNoMV, GenCheckStmtConditions, GenCheckStmtRatios), expected: genCheckNoMV}, | ||
"genCheck_NoClustering": {received: testschema.UpdateFuncCases(&tableNoClustering, GenCheckStmtConditions, GenCheckStmtRatios), expected: genCheckNoClustering}, | ||
"genCheck_Min": {received: testschema.UpdateFuncCases(&tableMin, GenCheckStmtConditions, GenCheckStmtRatios), expected: genCheckMin}, | ||
} | ||
compareResults(t, genCheckList) | ||
|
||
funcsList := testschema.UpdateFuncCases(&tableFull, GenCheckStmtConditions, GenCheckStmtRatios) | ||
idx := funcsList.RandomCase(rand.New(rand.NewSource(123))) | ||
_ = idx | ||
} | ||
|
||
func compareResults(t *testing.T, results map[string]comparer) { | ||
for caseName := range results { | ||
checkPresenceCases(t, caseName, results[caseName].received, results[caseName].expected...) | ||
} | ||
} | ||
|
||
func checkPresenceCases(t *testing.T, caseName string, funcs testschema.CasesInfo, expected ...int) { | ||
received := make([]int, 0, len(expected)) | ||
for i := range expected { | ||
for j := range funcs.List { | ||
if expected[i] == funcs.List[j].ID { | ||
received = append(received, expected[i]) | ||
break | ||
} | ||
} | ||
} | ||
if len(received) != len(expected) { | ||
t.Errorf("wrong function cases for case:%s \nexpected:%v \nreceived:%v ", caseName, expected, received) | ||
} | ||
} | ||
|
||
func getTestTable() testschema.Table { | ||
col := testschema.ColumnDef{ | ||
Name: "col_0", | ||
Type: coltypes.TYPE_INT, | ||
} | ||
cols := testschema.Columns{&col, &col} | ||
index := typedef.IndexDef{ | ||
Name: "id_1", | ||
Column: "col_0", | ||
ColumnIdx: 0, | ||
} | ||
return testschema.Table{ | ||
Name: "tb1", | ||
PartitionKeys: cols, | ||
ClusteringKeys: cols, | ||
Columns: cols, | ||
Indexes: typedef.Indexes{index, index}, | ||
MaterializedViews: cols.CreateMaterializedViews("mv1", cols, cols), | ||
KnownIssues: map[string]bool{ | ||
typedef.KnownIssuesJSONWithTuples: true, | ||
}, | ||
TableOptions: nil, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.