diff --git a/cmd/e2e-test/clickhouse.go b/cmd/e2e-test/clickhouse.go index a234a8d8..04574722 100644 --- a/cmd/e2e-test/clickhouse.go +++ b/cmd/e2e-test/clickhouse.go @@ -32,7 +32,6 @@ type Clickhouse struct { url string `toml:"-"` tlsurl string `toml:"-"` container string `toml:"-"` - client *http.Client } func (c *Clickhouse) CheckConfig(rootDir string) error { @@ -75,7 +74,6 @@ func (c *Clickhouse) Start() (string, error) { return "", err } port := strings.Split(c.httpAddress, ":")[1] - c.client = http.DefaultClient c.url = "http://" + c.httpAddress c.container = ClickhouseContainerName @@ -155,11 +153,8 @@ func (c *Clickhouse) URL() string { return c.url } -func (c *Clickhouse) TLSURL() (string, bool) { - if c.tlsurl == "" { - return "", false - } - return c.tlsurl, true +func (c *Clickhouse) TLSURL() string { + return c.tlsurl } func (c *Clickhouse) Container() string { @@ -177,7 +172,7 @@ func (c *Clickhouse) Query(sql string) (string, error) { return "", err } - resp, err := c.client.Do(request) + resp, err := http.DefaultClient.Do(request) if err != nil { return "", err } @@ -191,15 +186,11 @@ func (c *Clickhouse) Query(sql string) (string, error) { return string(msg), nil } -func (c *Clickhouse) SetClient(client *http.Client) { - c.client = client -} - func (c *Clickhouse) Alive() bool { if len(c.container) == 0 { return false } - req, err := http.DefaultClient.Get("http://" + c.httpAddress) + req, err := http.DefaultClient.Get(c.URL()) if err != nil { return false } diff --git a/cmd/e2e-test/e2etesting.go b/cmd/e2e-test/e2etesting.go index fa4ab04b..04e545c5 100644 --- a/cmd/e2e-test/e2etesting.go +++ b/cmd/e2e-test/e2etesting.go @@ -3,7 +3,6 @@ package main import ( "bufio" "bytes" - "errors" "fmt" "io/ioutil" "net" @@ -174,16 +173,17 @@ func testCarbonClickhouse( ConfigTpl: testDir + "/" + test.ConfigTpl, TestDir: absoluteDir, } + var ( + tlsurl string + ) if test.HasTLSSettings() { - url, exists := clickhouse.TLSURL() - if exists { - err = cch.Start(clickhouse.URL(), url) - } else { - err = errors.New("test has tls settings but there is no clickhouse tls url") + tlsurl = clickhouse.TLSURL() + if tlsurl == "" { + logger.Error("test has tls settings but there is no clickhouse tls url") + return false } - } else { - err = cch.Start(clickhouse.URL(), "") } + err = cch.Start(clickhouse.URL(), tlsurl) if err != nil { logger.Error("starting carbon-clickhouse", zap.String("config", test.name), diff --git a/cmd/e2e-test/main.go b/cmd/e2e-test/main.go index 1e3db251..1378561c 100644 --- a/cmd/e2e-test/main.go +++ b/cmd/e2e-test/main.go @@ -4,15 +4,12 @@ import ( "flag" "io/ioutil" "log" - "net/http" "os" "path" "runtime" "time" "go.uber.org/zap" - - helpercfg "github.com/lomik/carbon-clickhouse/helper/config" ) type MainConfig struct { @@ -136,8 +133,7 @@ func main() { failed := 0 total := 0 - for chVersion := range chVersions { - ch := chVersions[chVersion] + for chVersion, ch := range chVersions { if exist, out := containerExist(ClickhouseContainerName); exist { logger.Error("clickhouse already exist", zap.String("container", ClickhouseContainerName), @@ -170,23 +166,6 @@ func main() { total++ } else { for _, config := range configs { - testDir := config.Test.dir - client := &http.Client{Timeout: time.Minute} - if ch.TLSEnabled && config.Test.HasTLSSettings() { - conf, err := helpercfg.ParseClientTLSConfig(&helpercfg.TLS{ - Certificates: []helpercfg.CertificatePair{{testDir + "/client.key", testDir + "/client.crt"}}, - CACertFiles: []string{testDir + "/ca.crt"}, - }) - if err != nil { - logger.Error("failed to parse tls") - failed += len(config.Test.InputTypes) - } - client.Transport = &http.Transport{ - TLSClientConfig: conf, - DisableKeepAlives: true, - } - } - ch.SetClient(client) if config.Test.chVersions[chVersion] { testFailed, testTotal := runTest(config, &ch, rootDir, *verbose, *breakOnError, logger) failed += testFailed