github.com/dolthub/dolt/go@v0.40.5-0.20240520175717-68db7794bea6/performance/import_benchmarker/cmd/main.go (about) 1 // Copyright 2019 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "flag" 19 "fmt" 20 "log" 21 "os" 22 23 driver "github.com/dolthub/dolt/go/libraries/doltcore/dtestutils/sql_server_driver" 24 ib "github.com/dolthub/dolt/go/performance/import_benchmarker" 25 ) 26 27 const ( 28 resultsTableName = "results" 29 ) 30 31 var path = flag.String("test", "", "the path to a test file") 32 var out = flag.String("out", "", "result output path") 33 34 func main() { 35 flag.Parse() 36 def, err := ib.ParseTestsFile(*path) 37 if err != nil { 38 log.Fatalln(err) 39 } 40 41 tmpdir, err := os.MkdirTemp("", "repo-store-") 42 if err != nil { 43 log.Fatalln(err) 44 } 45 46 results := new(ib.ImportResults) 47 u, err := driver.NewDoltUser() 48 for _, test := range def.Tests { 49 test.Results = results 50 test.InitWithTmpDir(tmpdir) 51 52 for _, r := range test.Repos { 53 var err error 54 switch { 55 case r.ExternalServer != nil: 56 err = test.RunExternalServerTests(r.Name, r.ExternalServer) 57 case r.Server != nil: 58 err = test.RunSqlServerTests(r, u) 59 default: 60 err = test.RunCliTests(r, u) 61 } 62 if err != nil { 63 log.Fatalln(err) 64 } 65 } 66 } 67 if *out != "" { 68 of, err := os.Create(*out) 69 if err != nil { 70 log.Fatalln(err) 71 } 72 fmt.Fprintf(of, results.SqlDump()) 73 } else { 74 fmt.Println(results.SqlDump()) 75 } 76 os.Exit(0) 77 }