Skip to content

Commit

Permalink
fix: removed test assertions for daily index in TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
lordvidex committed Jul 22, 2023
1 parent 5ca3514 commit a4cc2ec
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 57 deletions.
19 changes: 12 additions & 7 deletions cmd/e2e-test/carbon_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import (
type CarbonClickhouse struct {
Binary string `toml:"binary"`
ConfigTpl string `toml:"template"`
TestDir string `toml:"-"`

storeDir string `toml:"-"`
configFile string `toml:"-"`
address string `toml:"-"`
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")
}
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 10 additions & 6 deletions cmd/e2e-test/e2etesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -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()}
}
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions tests/tls/carbon-clickhouse.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }}"
Expand Down
36 changes: 0 additions & 36 deletions tests/tls/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
]

0 comments on commit a4cc2ec

Please sign in to comment.