diff --git a/cmd/e2e-test/carbon_clickhouse.go b/cmd/e2e-test/carbon_clickhouse.go index 23ad8612..d8b96087 100644 --- a/cmd/e2e-test/carbon_clickhouse.go +++ b/cmd/e2e-test/carbon_clickhouse.go @@ -14,6 +14,7 @@ import ( type CarbonClickhouse struct { Binary string `toml:"binary"` ConfigTpl string `toml:"template"` + TestDir string `toml:"-"` storeDir string `toml:"-"` configFile string `toml:"-"` @@ -21,7 +22,7 @@ type CarbonClickhouse struct { cmd *exec.Cmd `toml:"-"` } -func (c *CarbonClickhouse) Start(clickhouseURL string) error { +func (c *CarbonClickhouse) Start(clickhouseURL string, clickhouseTLSURL string) error { if c.cmd != nil { return fmt.Errorf("carbon-clickhouse already started") } @@ -52,13 +53,17 @@ func (c *CarbonClickhouse) Start(clickhouseURL string) error { return err } param := struct { - CLICKHOUSE_URL string - CCH_STORE_DIR string - CCH_ADDR string + CLICKHOUSE_URL string + CLICKHOUSE_TLS_URL string + CCH_STORE_DIR string + CCH_ADDR string + TEST_DIR string }{ - CLICKHOUSE_URL: clickhouseURL, - CCH_STORE_DIR: c.storeDir, - CCH_ADDR: c.address, + CLICKHOUSE_URL: clickhouseURL, + CLICKHOUSE_TLS_URL: clickhouseTLSURL, + CCH_STORE_DIR: c.storeDir, + CCH_ADDR: c.address, + TEST_DIR: c.TestDir, } c.configFile = path.Join(c.storeDir, "carbon-clickhouse.conf") diff --git a/cmd/e2e-test/e2etesting.go b/cmd/e2e-test/e2etesting.go index 025b245d..fa4ab04b 100644 --- a/cmd/e2e-test/e2etesting.go +++ b/cmd/e2e-test/e2etesting.go @@ -10,6 +10,7 @@ import ( "net/http" "os" "path" + "path/filepath" "strings" "time" @@ -119,7 +120,7 @@ func verifyOut(ch *Clickhouse, verify Verify) []string { if err != nil { return []string{err.Error()} } - resp, err := ch.client.Do(req) + resp, err := http.DefaultClient.Do(req) if err != nil { return []string{err.Error()} } @@ -163,22 +164,25 @@ func testCarbonClickhouse( err := clickhouse.CheckConfig(rootDir) if err != nil { - testSuccess = false - return + return false + } + absoluteDir, err := filepath.Abs(test.dir) + if err != nil { + return false } - cch := CarbonClickhouse{ ConfigTpl: testDir + "/" + test.ConfigTpl, + TestDir: absoluteDir, } if test.HasTLSSettings() { url, exists := clickhouse.TLSURL() if exists { - err = cch.Start(url) + err = cch.Start(clickhouse.URL(), url) } else { err = errors.New("test has tls settings but there is no clickhouse tls url") } } else { - err = cch.Start(clickhouse.URL()) + err = cch.Start(clickhouse.URL(), "") } if err != nil { logger.Error("starting carbon-clickhouse", diff --git a/tests/tls/carbon-clickhouse.conf.tpl b/tests/tls/carbon-clickhouse.conf.tpl index 2c21efe8..2e774224 100644 --- a/tests/tls/carbon-clickhouse.conf.tpl +++ b/tests/tls/carbon-clickhouse.conf.tpl @@ -9,17 +9,17 @@ chunk-auto-interval = "" [upload.graphite_index] type = "index" table = "graphite_index" -url = "{{ .CLICKHOUSE_URL }}/" +url = "{{ .CLICKHOUSE_TLS_URL }}/" timeout = "2m30s" cache-ttl = "1h" disable-daily-index = true [upload.graphite_index.tls] -ca-cert = [ "tests/tls/rootCA.crt"] +ca-cert = [ "{{- .TEST_DIR -}}/ca.crt"] server-name = "localhost" insecure-skip-verify = false [[upload.graphite_index.tls.certificates]] -key = "tests/tls/client.key" -cert = "tests/tls/client.crt" +key = "{{- .TEST_DIR -}}/client.key" +cert = "{{- .TEST_DIR -}}/client.crt" [upload.graphite_tags] type = "tagged" @@ -39,16 +39,16 @@ zero-timestamp = true [upload.graphite] type = "points" table = "graphite" -url = "{{ .CLICKHOUSE_URL }}/" +url = "{{ .CLICKHOUSE_TLS_URL }}/" timeout = "2m30s" zero-timestamp = true [upload.graphite.tls] -ca-cert = [ "tests/tls/rootCA.crt"] +ca-cert = [ "{{- .TEST_DIR -}}/ca.crt"] server-name = "localhost" insecure-skip-verify = false [[upload.graphite.tls.certificates]] -key = "tests/tls/client.key" -cert = "tests/tls/client.crt" +key = "{{- .TEST_DIR -}}/client.key" +cert = "{{- .TEST_DIR -}}/client.crt" [tcp] listen = "{{ .CCH_ADDR }}" diff --git a/tests/tls/test.toml b/tests/tls/test.toml index acd9fc38..83ec34db 100644 --- a/tests/tls/test.toml +++ b/tests/tls/test.toml @@ -118,8 +118,6 @@ output = [ "1970-02-12 20003 test.host1.cpu.", "1970-02-12 20004 test.host1.cpu.loadavg", "1970-02-12 30004 loadavg.cpu.host1.test", - "2021-07-05 4 test.host1.cpu.loadavg", - "2021-07-05 10004 loadavg.cpu.host1.test", ] [[test.verify]] query = "SELECT Path, Value, Time, Date, Timestamp FROM graphite WHERE Path LIKE 'test.%' ORDER BY Time, Path" @@ -156,37 +154,3 @@ output = [ "cpu.loadavg?env=test&host=host1 21.4 1625478300 2021-07-05 0", "cpu.loadavg?env=test&host=host1 1.3 1625478360 2021-07-05 0", ] - -# Tests for issue #116 -# spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward=/ 5.1 1625478360 -[[test.verify]] -query = "SELECT Date, Tag1, Path, arraySort(Tags) as Tags FROM graphite_tags WHERE Path LIKE 'spec_symbols?%' ORDER BY Date, Tag1, Path" -output = [ - "2021-07-05 __name__=spec_symbols spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 colon=: spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 forward=/ spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 hash=# spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 minus=- spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 percent=% spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 plus=+ spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 underscore=_ spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']" -] -[[test.verify]] -query = "SELECT Path, Value, Time, Date, Timestamp FROM graphite WHERE Path LIKE 'spec_symbols?%' ORDER BY Time, Path" -output = [ - "spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ 5.1 1625478360 2021-07-05 0" -] - -# Tests for non-ASCII symbols in path -# non-ascii.иван;tagged=true 1.2 1625478240 -[[test.verify]] -query = "SELECT Date, Tag1, Path, arraySort(Tags) as Tags FROM graphite_tags WHERE Path LIKE 'non-ascii.%?%' ORDER BY Date, Tag1, Path" -output = [ - "2021-07-05 __name__=non-ascii.иван non-ascii.%D0%B8%D0%B2%D0%B0%D0%BD?tagged=true ['__name__=non-ascii.иван','tagged=true']", - "2021-07-05 tagged=true non-ascii.%D0%B8%D0%B2%D0%B0%D0%BD?tagged=true ['__name__=non-ascii.иван','tagged=true']" -] -[[test.verify]] -query = "SELECT Path, Value, Time, Date, Timestamp FROM graphite WHERE Path LIKE 'non-ascii.%?%' ORDER BY Time, Path" -output = [ - "non-ascii.%D0%B8%D0%B2%D0%B0%D0%BD?tagged=true 1.2 1625478240 2021-07-05 0" -]