Skip to content

Commit

Permalink
Merge pull request #1250 from antip00/0.22.0_logs_container_customizing
Browse files Browse the repository at this point in the history
Adding tests for log container customizing.
  • Loading branch information
Slach authored Oct 6, 2023
2 parents 505fd64 + b6dc9b2 commit 295c374
Show file tree
Hide file tree
Showing 5 changed files with 4,309 additions and 5,066 deletions.
32 changes: 32 additions & 0 deletions tests/e2e/manifests/chi/test-043-0-logs-container-customizing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: clickhouse.altinity.com/v1
kind: ClickHouseInstallation
metadata:
name: test-043-0-logs-customization
spec:
templates:
podTemplates:
- name: pod-template
spec:
containers:
- name: clickhouse
image: clickhouse/clickhouse-server:22.3
- name: clickhouse-log
image: registry.access.redhat.com/ubi8/ubi-minimal:latest
command:
- "/bin/sh"
- "-c"
- "--"
args:
- "while true; do sleep 30; done;"
volumeClaimTemplates:
- name: log-volume-template
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
defaults:
templates:
podTemplate: pod-template
logVolumeClaimTemplate: log-volume-template
24 changes: 24 additions & 0 deletions tests/e2e/manifests/chi/test-043-1-logs-container-customizing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: clickhouse.altinity.com/v1
kind: ClickHouseInstallation
metadata:
name: test-043-1-logs-customization
spec:
templates:
podTemplates:
- name: pod-template
spec:
containers:
- name: clickhouse
image: clickhouse/clickhouse-server:22.3
volumeClaimTemplates:
- name: log-volume-template
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
defaults:
templates:
podTemplate: pod-template
logVolumeClaimTemplate: log-volume-template
62 changes: 62 additions & 0 deletions tests/e2e/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,68 @@ def test_042(self):

delete_test_namespace()


@TestCheck
@Name("test_043. Logs container customizing")
def test_043(self, manifest):
"""Check that clickhouse-operator support logs container customizing."""

cluster = "cluster"
chi = yaml_manifest.get_chi_name(util.get_full_path(manifest))

with Given("CHI is installed"):
kubectl.create_and_check(
manifest=manifest,
check={
"pod_count": 1,
"do_not_delete": 1,
},
)

with Then("I check both containers are ready"):
assert kubectl.get_field(
kind="pod",
name=f"chi-{chi}-{cluster}-0-0-0",
field=".status.containerStatuses[0].ready"
) == "true", error()
assert kubectl.get_field(
kind="pod",
name=f"chi-{chi}-{cluster}-0-0-0",
field=".status.containerStatuses[1].ready"
) == "true", error()

with Then("I check clickhouse logs are in clickhouse-log container"):
with By("calling ls inside clickhouse-log in /var/log directory"):
r = kubectl.launch(f"exec chi-{chi}-{cluster}-0-0-0 -c clickhouse-log -- bash -c 'ls /var/log/clickhouse-server/'")

assert "clickhouse-server.err.log" in r
assert "clickhouse-server.log" in r

kubectl.delete_chi(chi)

delete_test_namespace()


@TestScenario
@Requirements(RQ_SRS_026_ClickHouseOperator_CustomResource_Spec_Defaults_Templates_logVolumeClaimTemplate("1.0"))
@Name("test_043_0. Logs container customizing using PodTemplate")
def test_043_0(self):
"""Check that clickhouse-operator support manual logs container customizing."""
create_shell_namespace_clickhouse_template()

test_043(manifest="manifests/chi/test-043-0-logs-container-customizing.yaml")


@TestScenario
@Requirements(RQ_SRS_026_ClickHouseOperator_CustomResource_Spec_Defaults_Templates_logVolumeClaimTemplate("1.0"))
@Name("test_043_1. Default clickhouse-log container")
def test_043_1(self):
"""Check that clickhouse-operator sets up default logs container if it is not specified in Pod."""
create_shell_namespace_clickhouse_template()

test_043(manifest="manifests/chi/test-043-1-logs-container-customizing.yaml")


@TestModule
@Name("e2e.test_operator")
@Requirements(RQ_SRS_026_ClickHouseOperator_CustomResource_APIVersion("1.0"))
Expand Down
11 changes: 7 additions & 4 deletions tests/requirements/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ of a specific host such as hostname, ports etc. as well as to define host networ
##### RQ.SRS-026.ClickHouseOperator.VolumeClaimTamplates
version: 1.0

[ClickHouse Operator] SHALL volume claim tamplates of the following types
[ClickHouse Operator] SHALL volume claim templates of the following types

* log volume claim using `logVolumeClaimTemplate`
* data volume claim using `dataVolumeClaimTemplate`
Expand Down Expand Up @@ -2081,7 +2081,9 @@ version: 1.0
of [string] type that SHALL specify template name from `.spec.templates.volumeClaimTemplates`
that SHALL allow customization of each [PVC] which will mount for clickhouse log directory
in each [Pod] during render and reconcile every `StatefulSet.spec` resource described
in `.spec.configuration.clusters`.
in `.spec.configuration.clusters`. If `.defaults.templates.logVolumeClaimTemplate` is
specified, and no container named `clickhouse-log` specified in [Pod], [ClickHouse Operator] SHALL
create new container for logs with name `clickhouse-log` and image `registry.access.redhat.com/ubi8/ubi-minimal:latest`.

For example,

Expand Down Expand Up @@ -2235,7 +2237,7 @@ Each item of the array SHALL specify the following properties:
For example,

```yaml
spec
spec:
configuration:
zookeeper:
nodes:
Expand Down Expand Up @@ -2795,6 +2797,7 @@ spec:
shards:
- name: custom-shard-name
internalReplication: 1
```

##### Shard Settings

Expand Down Expand Up @@ -3204,7 +3207,7 @@ spec:
layout:
replicas:
- name: replica0
settings:
settings:
```

##### Replica Files
Expand Down
Loading

0 comments on commit 295c374

Please sign in to comment.