-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
86039: kvserver: record paused replica message drops to a metric r=tbg a=pavelkalinnikov Part of #83917 Release justification: The metric may help investigating issues with paused replicas Release note: None 86200: sql/schemachanger: Initial support for generating a corpus r=fqazi a=fqazi These changes introduce the following: 1. Support for gathering declarative schema changer states (corpus) from logictests to help backwards/mixed version compatibility testing 2. Debug command support for replaying corpuses 3. Optional test for testing a generated corpus when a parameter is specified Release justification: Mainly test enhancements that are disabled by default, which will allow us to have an automated workload to test declarative schema changer state between versions. Co-authored-by: Pavel Kalinnikov <[email protected]> Co-authored-by: Faizan Qazi <[email protected]>
- Loading branch information
Showing
29 changed files
with
839 additions
and
84 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# cluster-opt: disable-corpus-generation | ||
statement ok | ||
SET use_declarative_schema_changer = 'unsafe' | ||
|
||
|
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
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,62 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/cli/clierrorplus" | ||
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb" | ||
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/corpus" | ||
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scop" | ||
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var declarativeValidateCorpus = &cobra.Command{ | ||
Use: "declarative-corpus-validate <filename>", | ||
Short: "validates a corpus file for the declarative schema changer", | ||
Long: ` | ||
Validates very single declarative schema changer state can be planned against in | ||
a given corpus file. | ||
`, | ||
Args: cobra.ExactArgs(1), | ||
RunE: clierrorplus.MaybeDecorateError( | ||
func(cmd *cobra.Command, args []string) (resErr error) { | ||
cr, err := corpus.NewCorpusReaderWithPath(args[0]) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = cr.ReadCorpus() | ||
if err != nil { | ||
panic(err) | ||
} | ||
for idx := 0; idx < cr.GetNumEntries(); idx++ { | ||
name, state := cr.GetCorpus(idx) | ||
jobID := jobspb.JobID(0) | ||
params := scplan.Params{ | ||
InRollback: state.InRollback, | ||
ExecutionPhase: scop.LatestPhase, | ||
SchemaChangerJobIDSupplier: func() jobspb.JobID { | ||
jobID++ | ||
return jobID | ||
}, | ||
} | ||
_, err := scplan.MakePlan(*state, params) | ||
if err != nil { | ||
fmt.Printf("failed to validate %s with error %v\n", name, err) | ||
} else { | ||
fmt.Printf("validated %s\n", name) | ||
} | ||
} | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package cli | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/testutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/datadriven" | ||
) | ||
|
||
// This test doctoring a secure cluster. | ||
func TestDeclarativeCorpus(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
c := NewCLITest(TestCLIParams{T: t, NoServer: true}) | ||
defer c.Cleanup() | ||
|
||
t.Run("declarative corpus validation standalone command", func(t *testing.T) { | ||
out, err := c.RunWithCapture("debug declarative-corpus-validate testdata/declarative-corpus/corpus") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Using datadriven allows TESTFLAGS=-rewrite. | ||
datadriven.RunTest(t, testutils.TestDataPath(t, "declarative-corpus", "corpus_expected"), func(t *testing.T, td *datadriven.TestData) string { | ||
return out | ||
}) | ||
}) | ||
} |
Binary file not shown.
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,6 @@ | ||
debug declarative-corpus-validate testdata/declarative-corpus/corpus | ||
---- | ||
debug declarative-corpus-validate testdata/declarative-corpus/corpus | ||
validated EndToEndCorpus_TestGenerateCorpus/drop_multiregion/DROP_DATABASE_multi_region_test_db_CASCADE/starting_DROP DATABASE multi_region_test_db CASCADE_0 | ||
validated EndToEndCorpus_TestGenerateCorpus/drop_multiregion/DROP_TABLE_multi_region_test_db.public.table_regional_by_row/starting_DROP TABLE multi_region_test_db.public.table_regional_by_row_0 | ||
validated EndToEndCorpus_TestGenerateCorpus/drop_multiregion/DROP_TABLE_multi_region_test_db.public.table_regional_by_table_CASCADE/starting_DROP TABLE multi_region_test_db.public.table_regional_by_table CASCADE_0 |
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.