-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]> Co-authored-by: Manan Gupta <[email protected]> Co-authored-by: Manan Gupta <[email protected]>
- Loading branch information
1 parent
9df99ee
commit d914e0e
Showing
7 changed files
with
661 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright 2024 The Vitess Authors. | ||
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. | ||
*/ | ||
|
||
package union | ||
|
||
import ( | ||
_ "embed" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"vitess.io/vitess/go/mysql" | ||
"vitess.io/vitess/go/test/endtoend/cluster" | ||
"vitess.io/vitess/go/test/endtoend/utils" | ||
) | ||
|
||
var ( | ||
clusterInstance *cluster.LocalProcessCluster | ||
vtParams mysql.ConnParams | ||
mysqlParams mysql.ConnParams | ||
keyspaceName = "ks" | ||
cell = "zone-1" | ||
|
||
//go:embed schema.sql | ||
schemaSQL string | ||
|
||
//go:embed vschema.json | ||
vschema string | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
defer cluster.PanicHandler(nil) | ||
flag.Parse() | ||
|
||
exitCode := func() int { | ||
clusterInstance = cluster.NewCluster(cell, "localhost") | ||
defer clusterInstance.Teardown() | ||
|
||
// Start topo server | ||
err := clusterInstance.StartTopo() | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
// Start keyspace | ||
keyspace := &cluster.Keyspace{ | ||
Name: keyspaceName, | ||
SchemaSQL: schemaSQL, | ||
VSchema: vschema, | ||
} | ||
err = clusterInstance.StartKeyspace(*keyspace, []string{"-80", "80-"}, 0, false) | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
// Start vtgate | ||
err = clusterInstance.StartVtgate() | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
vtParams = clusterInstance.GetVTParams(keyspaceName) | ||
|
||
// create mysql instance and connection parameters | ||
conn, closer, err := utils.NewMySQL(clusterInstance, keyspaceName, schemaSQL) | ||
if err != nil { | ||
fmt.Println(err) | ||
return 1 | ||
} | ||
defer closer() | ||
mysqlParams = conn | ||
return m.Run() | ||
}() | ||
os.Exit(exitCode) | ||
} |
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,291 @@ | ||
CREATE TABLE IF NOT EXISTS nation | ||
( | ||
N_NATIONKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
N_NAME | ||
CHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
N_REGIONKEY INTEGER NOT NULL, | ||
N_COMMENT VARCHAR | ||
( | ||
152 | ||
), | ||
PRIMARY KEY | ||
( | ||
N_NATIONKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS region | ||
( | ||
R_REGIONKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
R_NAME | ||
CHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
R_COMMENT VARCHAR | ||
( | ||
152 | ||
), | ||
PRIMARY KEY | ||
( | ||
R_REGIONKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS part | ||
( | ||
P_PARTKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
P_NAME | ||
VARCHAR | ||
( | ||
55 | ||
) NOT NULL, | ||
P_MFGR CHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
P_BRAND CHAR | ||
( | ||
10 | ||
) NOT NULL, | ||
P_TYPE VARCHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
P_SIZE INTEGER NOT NULL, | ||
P_CONTAINER CHAR | ||
( | ||
10 | ||
) NOT NULL, | ||
P_RETAILPRICE DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
P_COMMENT VARCHAR | ||
( | ||
23 | ||
) NOT NULL, | ||
PRIMARY KEY | ||
( | ||
P_PARTKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS supplier | ||
( | ||
S_SUPPKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
S_NAME | ||
CHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
S_ADDRESS VARCHAR | ||
( | ||
40 | ||
) NOT NULL, | ||
S_NATIONKEY INTEGER NOT NULL, | ||
S_PHONE CHAR | ||
( | ||
15 | ||
) NOT NULL, | ||
S_ACCTBAL DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
S_COMMENT VARCHAR | ||
( | ||
101 | ||
) NOT NULL, | ||
PRIMARY KEY | ||
( | ||
S_SUPPKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS partsupp | ||
( | ||
PS_PARTKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
PS_SUPPKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
PS_AVAILQTY | ||
INTEGER | ||
NOT | ||
NULL, | ||
PS_SUPPLYCOST | ||
DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
PS_COMMENT VARCHAR | ||
( | ||
199 | ||
) NOT NULL, | ||
PRIMARY KEY | ||
( | ||
PS_PARTKEY, | ||
PS_SUPPKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS customer | ||
( | ||
C_CUSTKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
C_NAME | ||
VARCHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
C_ADDRESS VARCHAR | ||
( | ||
40 | ||
) NOT NULL, | ||
C_NATIONKEY INTEGER NOT NULL, | ||
C_PHONE CHAR | ||
( | ||
15 | ||
) NOT NULL, | ||
C_ACCTBAL DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
C_MKTSEGMENT CHAR | ||
( | ||
10 | ||
) NOT NULL, | ||
C_COMMENT VARCHAR | ||
( | ||
117 | ||
) NOT NULL, | ||
PRIMARY KEY | ||
( | ||
C_CUSTKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS orders | ||
( | ||
O_ORDERKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
O_CUSTKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
O_ORDERSTATUS | ||
CHAR | ||
( | ||
1 | ||
) NOT NULL, | ||
O_TOTALPRICE DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
O_ORDERDATE DATE NOT NULL, | ||
O_ORDERPRIORITY CHAR | ||
( | ||
15 | ||
) NOT NULL, | ||
O_CLERK CHAR | ||
( | ||
15 | ||
) NOT NULL, | ||
O_SHIPPRIORITY INTEGER NOT NULL, | ||
O_COMMENT VARCHAR | ||
( | ||
79 | ||
) NOT NULL, | ||
PRIMARY KEY | ||
( | ||
O_ORDERKEY | ||
)); | ||
|
||
CREATE TABLE IF NOT EXISTS lineitem | ||
( | ||
L_ORDERKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
L_PARTKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
L_SUPPKEY | ||
INTEGER | ||
NOT | ||
NULL, | ||
L_LINENUMBER | ||
INTEGER | ||
NOT | ||
NULL, | ||
L_QUANTITY | ||
DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
L_EXTENDEDPRICE DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
L_DISCOUNT DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
L_TAX DECIMAL | ||
( | ||
15, | ||
2 | ||
) NOT NULL, | ||
L_RETURNFLAG CHAR | ||
( | ||
1 | ||
) NOT NULL, | ||
L_LINESTATUS CHAR | ||
( | ||
1 | ||
) NOT NULL, | ||
L_SHIPDATE DATE NOT NULL, | ||
L_COMMITDATE DATE NOT NULL, | ||
L_RECEIPTDATE DATE NOT NULL, | ||
L_SHIPINSTRUCT CHAR | ||
( | ||
25 | ||
) NOT NULL, | ||
L_SHIPMODE CHAR | ||
( | ||
10 | ||
) NOT NULL, | ||
L_COMMENT VARCHAR | ||
( | ||
44 | ||
) NOT NULL, | ||
PRIMARY KEY | ||
( | ||
L_ORDERKEY, | ||
L_LINENUMBER | ||
)); |
Oops, something went wrong.