-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve unit tests coverage to 49.8%
- Loading branch information
1 parent
4927459
commit 58e5956
Showing
21 changed files
with
628 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<yandex> | ||
<!-- This xml file contains every node's special configuration self. --> | ||
<interserver_http_host>192.168.0.3</interserver_http_host> | ||
<macros> | ||
<cluster>test</cluster> | ||
<shard>2</shard> | ||
<replica>192.168.0.3</replica> | ||
</macros> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ckconfig | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/housepower/ckman/model" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestHosts(t *testing.T) { | ||
conf := model.CKManClickHouseConfig{ | ||
Cluster: "test", | ||
Shards: []model.CkShard{ | ||
{[]model.CkReplica{ | ||
{HostName: "ck01", Ip: "192.168.0.1"}, | ||
{HostName: "ck02", Ip: "192.168.0.2"}, | ||
}}, | ||
{[]model.CkReplica{ | ||
{HostName: "ck03", Ip: "192.168.0.3"}, | ||
{HostName: "ck04", Ip: "192.168.0.4"}, | ||
}}, | ||
}, | ||
} | ||
_, err := GenerateHostXML("hosts_fake.xml", &conf, "192.168.0.3") | ||
assert.Nil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<yandex> | ||
<zookeeper> | ||
<node index="1"> | ||
<host>192.168.0.1</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="2"> | ||
<host>192.168.0.2</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="3"> | ||
<host>192.168.0.3</host> | ||
<port>2181</port> | ||
</node> | ||
</zookeeper> | ||
<remote_servers> | ||
<test> | ||
<!-- Inter-server per-cluster secret for Distributed queries | ||
default: no secret (no authentication will be performed) | ||
If set, then Distributed queries will be validated on shards, so at least: | ||
- such cluster should exist on the shard, | ||
- such cluster should have the same secret. | ||
And also (and which is more important), the initial_user will | ||
be used as current user for the query. | ||
Right now the protocol is pretty simple and it only takes into account: | ||
- cluster name | ||
- query | ||
Also it will be nice if the following will be implemented: | ||
- source hostname (see interserver_http_host), but then it will depends from DNS, | ||
it can use IP address instead, but then the you need to get correct on the initiator node. | ||
- target hostname / ip address (same notes as for source hostname) | ||
- time-based security tokens --> | ||
<secret>foo</secret> | ||
<shard> | ||
<internal_replication>true</internal_replication> | ||
<replica> | ||
<host>192.168.0.1</host> | ||
<port>0</port> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.2</host> | ||
<port>0</port> | ||
</replica> | ||
</shard> | ||
<shard> | ||
<internal_replication>true</internal_replication> | ||
<replica> | ||
<host>192.168.0.3</host> | ||
<port>0</port> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.4</host> | ||
<port>0</port> | ||
</replica> | ||
</shard> | ||
</test> | ||
</remote_servers> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<yandex> | ||
<zookeeper> | ||
<node index="1"> | ||
<host>192.168.0.1</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="2"> | ||
<host>192.168.0.2</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="3"> | ||
<host>192.168.0.3</host> | ||
<port>2181</port> | ||
</node> | ||
</zookeeper> | ||
<remote_servers> | ||
<test> | ||
<shard> | ||
<internal_replication>false</internal_replication> | ||
<replica> | ||
<host>192.168.0.1</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.2</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
</shard> | ||
<shard> | ||
<internal_replication>false</internal_replication> | ||
<replica> | ||
<host>192.168.0.3</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.4</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
</shard> | ||
</test> | ||
</remote_servers> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<yandex> | ||
<zookeeper> | ||
<node index="1"> | ||
<host>192.168.0.1</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="2"> | ||
<host>192.168.0.2</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="3"> | ||
<host>192.168.0.3</host> | ||
<port>2181</port> | ||
</node> | ||
</zookeeper> | ||
<remote_servers> | ||
<test> | ||
<!-- Inter-server per-cluster secret for Distributed queries | ||
default: no secret (no authentication will be performed) | ||
If set, then Distributed queries will be validated on shards, so at least: | ||
- such cluster should exist on the shard, | ||
- such cluster should have the same secret. | ||
And also (and which is more important), the initial_user will | ||
be used as current user for the query. | ||
Right now the protocol is pretty simple and it only takes into account: | ||
- cluster name | ||
- query | ||
Also it will be nice if the following will be implemented: | ||
- source hostname (see interserver_http_host), but then it will depends from DNS, | ||
it can use IP address instead, but then the you need to get correct on the initiator node. | ||
- target hostname / ip address (same notes as for source hostname) | ||
- time-based security tokens --> | ||
<secret>foo</secret> | ||
<shard> | ||
<internal_replication>true</internal_replication> | ||
<replica> | ||
<host>192.168.0.1</host> | ||
<port>0</port> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.2</host> | ||
<port>0</port> | ||
</replica> | ||
</shard> | ||
<shard> | ||
<internal_replication>true</internal_replication> | ||
<replica> | ||
<host>192.168.0.3</host> | ||
<port>0</port> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.4</host> | ||
<port>0</port> | ||
</replica> | ||
</shard> | ||
</test> | ||
</remote_servers> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<yandex> | ||
<zookeeper> | ||
<node index="1"> | ||
<host>192.168.0.1</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="2"> | ||
<host>192.168.0.2</host> | ||
<port>2181</port> | ||
</node> | ||
<node index="3"> | ||
<host>192.168.0.3</host> | ||
<port>2181</port> | ||
</node> | ||
</zookeeper> | ||
<remote_servers> | ||
<test> | ||
<shard> | ||
<internal_replication>false</internal_replication> | ||
<replica> | ||
<host>192.168.0.1</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.2</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
</shard> | ||
<shard> | ||
<internal_replication>false</internal_replication> | ||
<replica> | ||
<host>192.168.0.3</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
<replica> | ||
<host>192.168.0.4</host> | ||
<port>0</port> | ||
<user></user> | ||
<password></password> | ||
</replica> | ||
</shard> | ||
</test> | ||
</remote_servers> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ckconfig | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/housepower/ckman/model" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMetrika(t *testing.T) { | ||
logic := "logic_test" | ||
conf := model.CKManClickHouseConfig{ | ||
Cluster: "test", | ||
Shards: []model.CkShard{ | ||
{[]model.CkReplica{ | ||
{HostName: "ck01", Ip: "192.168.0.1"}, | ||
{HostName: "ck02", Ip: "192.168.0.2"}, | ||
}}, | ||
{[]model.CkReplica{ | ||
{HostName: "ck03", Ip: "192.168.0.3"}, | ||
{HostName: "ck04", Ip: "192.168.0.4"}, | ||
}}, | ||
}, | ||
ZkNodes: []string{"192.168.0.1", "192.168.0.2", "192.168.0.3"}, | ||
ZkPort: 2181, | ||
IsReplica: true, | ||
LogicCluster: &logic, | ||
Version: "22.8.8.3", | ||
} | ||
_, err := GenerateMetrikaXML("metrika_fake.xml", &conf) | ||
assert.Nil(t, err) | ||
|
||
_, err = GenerateMetrikaXMLwithLogic("metrika_logic_fake.xml", &conf, "") | ||
assert.Nil(t, err) | ||
|
||
conf.IsReplica = false | ||
conf.Version = "20.3.8.5" | ||
_, err = GenerateMetrikaXML("metrika_fake2.xml", &conf) | ||
assert.Nil(t, err) | ||
|
||
_, err = GenerateMetrikaXMLwithLogic("metrika_logic_fake2.xml", &conf, "") | ||
assert.Nil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.