common: clickHouse → clickhouse

Let's say that we use "ClickHouse" and "clickhouse".
This commit is contained in:
Vincent Bernat
2024-06-09 14:58:32 +02:00
parent 1be313a209
commit 297e04b95c
10 changed files with 19 additions and 19 deletions

View File

@@ -115,7 +115,7 @@ func (schema Schema) ClickHouseSortingKeys() []string {
// ClickHousePrimaryKeys returns the list of primary keys. // ClickHousePrimaryKeys returns the list of primary keys.
func (schema Schema) ClickHousePrimaryKeys() []string { func (schema Schema) ClickHousePrimaryKeys() []string {
cols := []string{} cols := []string{}
for _, key := range schema.clickHousePrimaryKeys { for _, key := range schema.clickhousePrimaryKeys {
cols = append(cols, key.String()) cols = append(cols, key.String())
} }
return cols return cols

View File

@@ -189,7 +189,7 @@ const (
// in `PrimaryKeys'. // in `PrimaryKeys'.
func flows() Schema { func flows() Schema {
return Schema{ return Schema{
clickHousePrimaryKeys: []ColumnKey{ clickhousePrimaryKeys: []ColumnKey{
ColumnTimeReceived, ColumnTimeReceived,
ColumnExporterAddress, ColumnExporterAddress,
ColumnEType, ColumnEType,

View File

@@ -11,7 +11,7 @@ import (
func TestFlowsClickHouse(t *testing.T) { func TestFlowsClickHouse(t *testing.T) {
c := NewMock(t) c := NewMock(t)
for _, key := range c.clickHousePrimaryKeys { for _, key := range c.clickhousePrimaryKeys {
if column := c.columnIndex[key]; column.Key == 0 { if column := c.columnIndex[key]; column.Key == 0 {
t.Errorf("primary key %q not a column", key) t.Errorf("primary key %q not a column", key)
} else { } else {

View File

@@ -51,7 +51,7 @@ func New(config Configuration) (*Component, error) {
if column.NoDisable { if column.NoDisable {
return nil, fmt.Errorf("column %q cannot be disabled", k) return nil, fmt.Errorf("column %q cannot be disabled", k)
} }
if slices.Contains(schema.clickHousePrimaryKeys, k) { if slices.Contains(schema.clickhousePrimaryKeys, k) {
return nil, fmt.Errorf("column %q cannot be disabled (primary key)", k) return nil, fmt.Errorf("column %q cannot be disabled (primary key)", k)
} }
column.Disabled = true column.Disabled = true
@@ -76,7 +76,7 @@ func New(config Configuration) (*Component, error) {
if column.NoDisable { if column.NoDisable {
return nil, fmt.Errorf("column %q cannot be present on main table only", k) return nil, fmt.Errorf("column %q cannot be present on main table only", k)
} }
if slices.Contains(schema.clickHousePrimaryKeys, k) { if slices.Contains(schema.clickhousePrimaryKeys, k) {
// Primary keys are part of the sorting key. // Primary keys are part of the sorting key.
return nil, fmt.Errorf("column %q cannot be present on main table only (primary key)", k) return nil, fmt.Errorf("column %q cannot be present on main table only (primary key)", k)
} }

View File

@@ -21,7 +21,7 @@ type Schema struct {
dynamicColumns ColumnKey dynamicColumns ColumnKey
// For ClickHouse. This is the set of primary keys (order is important and // For ClickHouse. This is the set of primary keys (order is important and
// may not follow column order) for the aggregated tables. // may not follow column order) for the aggregated tables.
clickHousePrimaryKeys []ColumnKey clickhousePrimaryKeys []ColumnKey
} }
// Column represents a column of data. // Column represents a column of data.

View File

@@ -18,7 +18,7 @@ import (
func TestHTTPEndpoints(t *testing.T) { func TestHTTPEndpoints(t *testing.T) {
r := reporter.NewMock(t) r := reporter.NewMock(t)
clickHouseComponent := clickhousedb.SetupClickHouse(t, r, false) clickhouseComponent := clickhousedb.SetupClickHouse(t, r, false)
config := DefaultConfiguration() config := DefaultConfiguration()
config.SkipMigrations = true config.SkipMigrations = true
config.Networks = helpers.MustNewSubnetMap(map[string]NetworkAttributes{ config.Networks = helpers.MustNewSubnetMap(map[string]NetworkAttributes{
@@ -44,7 +44,7 @@ func TestHTTPEndpoints(t *testing.T) {
HTTP: httpserver.NewMock(t, r), HTTP: httpserver.NewMock(t, r),
Schema: sch, Schema: sch,
GeoIP: geoip.NewMock(t, r, false), GeoIP: geoip.NewMock(t, r, false),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)
@@ -113,7 +113,7 @@ func TestHTTPEndpoints(t *testing.T) {
func TestAdditionalASNs(t *testing.T) { func TestAdditionalASNs(t *testing.T) {
r := reporter.NewMock(t) r := reporter.NewMock(t)
clickHouseComponent := clickhousedb.SetupClickHouse(t, r, false) clickhouseComponent := clickhousedb.SetupClickHouse(t, r, false)
config := DefaultConfiguration() config := DefaultConfiguration()
config.ASNs = map[uint32]string{ config.ASNs = map[uint32]string{
1: "New network", 1: "New network",
@@ -123,7 +123,7 @@ func TestAdditionalASNs(t *testing.T) {
HTTP: httpserver.NewMock(t, r), HTTP: httpserver.NewMock(t, r),
Schema: schema.NewMock(t), Schema: schema.NewMock(t),
GeoIP: geoip.NewMock(t, r, false), GeoIP: geoip.NewMock(t, r, false),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)

View File

@@ -57,7 +57,7 @@ func (c *Component) migrateDatabase() error {
c.config.Kafka.Consumers = int(threads) c.config.Kafka.Consumers = int(threads)
} }
if err := validateVersion(version); err != nil { if err := validateVersion(version); err != nil {
return fmt.Errorf("incorrect Clickhouse version: %w", err) return fmt.Errorf("incorrect ClickHouse version: %w", err)
} }
if c.config.Cluster != "" { if c.config.Cluster != "" {

View File

@@ -173,14 +173,14 @@ func waitMigrations(t *testing.T, ch *Component) {
func TestGetHTTPBaseURL(t *testing.T) { func TestGetHTTPBaseURL(t *testing.T) {
r := reporter.NewMock(t) r := reporter.NewMock(t)
clickHouseComponent := clickhousedb.SetupClickHouse(t, r, false) clickhouseComponent := clickhousedb.SetupClickHouse(t, r, false)
http := httpserver.NewMock(t, r) http := httpserver.NewMock(t, r)
c, err := New(r, DefaultConfiguration(), Dependencies{ c, err := New(r, DefaultConfiguration(), Dependencies{
Daemon: daemon.NewMock(t), Daemon: daemon.NewMock(t),
HTTP: http, HTTP: http,
Schema: schema.NewMock(t), Schema: schema.NewMock(t),
GeoIP: geoip.NewMock(t, r, true), GeoIP: geoip.NewMock(t, r, true),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)

View File

@@ -21,7 +21,7 @@ func TestNetworksCSVWithGeoip(t *testing.T) {
config := DefaultConfiguration() config := DefaultConfiguration()
config.SkipMigrations = true config.SkipMigrations = true
r := reporter.NewMock(t) r := reporter.NewMock(t)
clickHouseComponent := clickhousedb.SetupClickHouse(t, r, false) clickhouseComponent := clickhousedb.SetupClickHouse(t, r, false)
t.Run("only GeoIP", func(t *testing.T) { t.Run("only GeoIP", func(t *testing.T) {
// First use only GeoIP // First use only GeoIP
@@ -30,7 +30,7 @@ func TestNetworksCSVWithGeoip(t *testing.T) {
HTTP: httpserver.NewMock(t, r), HTTP: httpserver.NewMock(t, r),
Schema: schema.NewMock(t), Schema: schema.NewMock(t),
GeoIP: geoip.NewMock(t, r, true), GeoIP: geoip.NewMock(t, r, true),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)
@@ -79,7 +79,7 @@ func TestNetworksCSVWithGeoip(t *testing.T) {
HTTP: httpserver.NewMock(t, r), HTTP: httpserver.NewMock(t, r),
Schema: schema.NewMock(t), Schema: schema.NewMock(t),
GeoIP: geoip.NewMock(t, r, true), GeoIP: geoip.NewMock(t, r, true),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)
@@ -126,7 +126,7 @@ func TestNetworksCSVWithGeoip(t *testing.T) {
HTTP: httpserver.NewMock(t, r), HTTP: httpserver.NewMock(t, r),
Schema: schema.NewMock(t), Schema: schema.NewMock(t),
GeoIP: geoip.NewMock(t, r, true), GeoIP: geoip.NewMock(t, r, true),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)

View File

@@ -24,7 +24,7 @@ import (
func TestNetworkSources(t *testing.T) { func TestNetworkSources(t *testing.T) {
r := reporter.NewMock(t) r := reporter.NewMock(t)
clickHouseComponent := clickhousedb.SetupClickHouse(t, r, false) clickhouseComponent := clickhousedb.SetupClickHouse(t, r, false)
// Mux to answer requests // Mux to answer requests
ready := make(chan bool) ready := make(chan bool)
@@ -104,7 +104,7 @@ func TestNetworkSources(t *testing.T) {
HTTP: httpserver.NewMock(t, r), HTTP: httpserver.NewMock(t, r),
Schema: schema.NewMock(t), Schema: schema.NewMock(t),
GeoIP: geoip.NewMock(t, r, false), GeoIP: geoip.NewMock(t, r, false),
ClickHouse: clickHouseComponent, ClickHouse: clickhouseComponent,
}) })
if err != nil { if err != nil {
t.Fatalf("New() error:\n%+v", err) t.Fatalf("New() error:\n%+v", err)