regtest

package
v0.0.0-...-9cbd515 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

Regression Test

PreBuild

Build images

You could build images from source if you would like to use the latest code.

# build image scql:latest
bash docker/build.sh

Test Central with Local Docker Compose

Customize images and port

You could customize scdbserver published port and container images and protocols by configuring env file .ci/docker-compose/.env.

Prepare docker files

If you want to test more than one protocols you can modify .ci/docker-compose/.env and set PROTOCOLS as the protocols which you want to test and separate them with commas. At the same time you must set scdb port for every protocol. Such as if you want to test protocols ABY3 and SEMI2K, you must set PROTOCOLS=ABY3,SEMI2K and SCDB_PORTS=8080,8081.

(cd .ci/docker-compose && python setup.py)

More to say: you may need run pip install -r requirements.txt when first time running docker-compose.

Turn up all containers
(cd .ci/docker-compose && docker compose -p regtest up -d)
Run regtest
# All test flags are stored in regtest.yml. If necessary, please modify the corresponding parameters in regtest.yml before running the tests.

# go test will use package path as working directory
go test ./cmd/regtest/scdb_test/... -v -count=1 -timeout=30m -args --conf=../../../.ci/docker-compose/regtest.yml


# you could run sql interactively if needed
# export `SCDB_PORTS` defined in `.ci/docker-compose/.env`
export $(grep -v '^#' .ci/docker-compose/.env | xargs)
go run cmd/scdbclient/main.go prompt --host="http://localhost:$SCDB_PORTS"
>switch alice;
alice> use scdb
alice> select ...
Turn down all containers
(cd .ci/docker-compose && docker compose -p regtest down)

Test P2P with Local Docker Compose

Customize images and port

You could customize scdbserver published port and container images and protocols by configuring env file .ci/broker-docker-compose/.env.

Prepare docker files
# please set SPU_PROTOCOL in .env file if you want to test ABY3 or CHEETAH
(cd .ci/broker-docker-compose && python setup.py)

More to say: you may need run pip install -r requirements.txt when first time running docker-compose.

Turn up all containers
(cd .ci/broker-docker-compose && docker compose -p regtest-p2p up -d)
Run regtest
# All test flags are stored in regtest.yml. If necessary, please modify the corresponding parameters in regtest.yml before running the tests.
# go test will use package path as working directory
go test ./cmd/regtest/p2p_test/... -v -count=1 -timeout=30m -args --conf=../../../.ci/broker-docker-compose/regtest.yml
Turn down all containers
(cd .ci/broker-docker-compose && docker compose -p regtest-p2p down)

Documentation

Index

Constants

View Source
const (
	NumericalPrecision float64 = 1e-1
)

NumericalPrecision is based on experiment

Variables

View Source
var (
	TableToPartyCode map[string]string
)

Functions

func AlmostEqual

func AlmostEqual(a, b float64) bool

func CheckResult

func CheckResult(testDataSource TestDataSource, expected *ResultTable, answer []*scql.Tensor, mysqlQueryString, errInfo string) (err error)

func FillTableToPartyCodeMap

func FillTableToPartyCodeMap(dbTables map[string][]*model.TableInfo)

func IsColumnNil

func IsColumnNil(col *ResultColumn) bool

Types

type QueryCase

type QueryCase struct {
	Name       string       `json:"name"`
	View       []string     `json:"view"`
	Query      string       `json:"query"`
	MySQLQuery string       `json:"mysql_query"`
	Result     *ResultTable `json:"result"`
}

type QueryTestSuit

type QueryTestSuit struct {
	Queries []QueryCase
}

type ResultColumn

type ResultColumn struct {
	Name    string    `json:"name"`
	Ss      []string  `json:"string"`
	Int64s  []int64   `json:"int"`
	Bools   []bool    `json:"bool"`
	Doubles []float64 `json:"float"`
}

func (*ResultColumn) ChangeOrders

func (c *ResultColumn) ChangeOrders(orders []int)

func (*ResultColumn) EqualTo

func (c *ResultColumn) EqualTo(o *ResultColumn) bool

type ResultTable

type ResultTable struct {
	Column []*ResultColumn `json:"column"`
}

func (*ResultTable) ConvertToRows

func (t *ResultTable) ConvertToRows() StringWithIds

func (*ResultTable) EqualTo

func (t *ResultTable) EqualTo(o *ResultTable) bool

type StringWithId

type StringWithId struct {
	// contains filtered or unexported fields
}

type StringWithIds

type StringWithIds []StringWithId

func (StringWithIds) GetOrders

func (x StringWithIds) GetOrders() []int

func (StringWithIds) Len

func (x StringWithIds) Len() int

func (StringWithIds) Less

func (x StringWithIds) Less(i, j int) bool

func (StringWithIds) Swap

func (x StringWithIds) Swap(i, j int)

type TestDataSource

type TestDataSource struct {
	MysqlDb *gorm.DB
}

func (*TestDataSource) ConnDB

func (ds *TestDataSource) ConnDB(conf *config.StorageConf) (err error)

connDB creates a connection to the MySQL instance

func (*TestDataSource) GetQueryResultFromMySQL

func (ds *TestDataSource) GetQueryResultFromMySQL(query string, needConvertDateTime bool) (curCaseResult *ResultTable, err error)

func (*TestDataSource) TruncateTable

func (ds *TestDataSource) TruncateTable(tableName string) error

Truncate table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL