Skip to content

Commit

Permalink
config: introduce new config format and parser
Browse files Browse the repository at this point in the history
For supporting multiple deployments in one cnf and
improving overall config usability and structure - new
config format has to be introduced.
Some existing parameters usage need to be changed
for easier adaptation.
This change does not replace the old config format.

Refs: cnti-testcatalog#2121
Signed-off-by: Konstantin Yarovoy <[email protected]>
  • Loading branch information
Konstantin Yarovoy committed Sep 5, 2024
1 parent c0f461e commit f1c5d67
Show file tree
Hide file tree
Showing 61 changed files with 315 additions and 134 deletions.
23 changes: 23 additions & 0 deletions embedded_files/cnf-testsuite-v2-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
config_version: "v2"
common:
container_names:
- name: coredns
rolling_update_test_tag: "1.8.0"
rolling_downgrade_test_tag: 1.6.7
rolling_version_change_test_tag: 1.8.0
rollback_from_tag: 1.8.0

deployments:
helm_charts:
- name: coredns
helm_repo_name: stable
helm_repo_url: https://cncf.gitlab.io/stable
helm_chart_name: coredns
# helm_dirs:
# - name: envoy
# helm_directory: ../example-cnfs/envoy/envoy
# manifests:
# - name: nginx
# manifest_directory: manifests

1 change: 0 additions & 1 deletion example-cnfs/envoy/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
release_name: envoy
service_name: envoy
helm_directory: envoy
1 change: 0 additions & 1 deletion example-cnfs/ip-forwarder/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
helm_directory: vpp
release_name: vpp
service_name: ""
rolling_update_test_tag: latest
allowlist_helm_chart_container_names: [nginx, calico-node, kube-proxy, nginx-proxy, node-cache, kube-multus]
1 change: 0 additions & 1 deletion example-cnfs/nsm/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
helm_directory: helm_chart
release_name: nsm --set insecure=true
service_name: nsm-admission-webhook-svc
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
1 change: 0 additions & 1 deletion example-cnfs/pantheon-nsm-nat/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
helm_directory: nat-cnf
release_name: cnf-nat
service_name:
allowlist_helm_chart_container_names: [node-cache, nginx, coredns, calico-node, kube-proxy, nginx-proxy, kube-multus]
1 change: 0 additions & 1 deletion sample-cnfs/k8s-multiple-deployments/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
helm_directory: chart
release_name: sidecar-container-demo
service_name:
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
1 change: 0 additions & 1 deletion sample-cnfs/k8s-multiple-processes/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
helm_directory: chart
release_name: sidecar-container-demo
service_name:
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ helm_directory: chart
git_clone_url:
install_script:
release_name: sidecar-container-demo
service_name:
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-bad-helm-repo/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns
service_name: coredns-coredns
helm_repository:
name: badrepo
repo_url: https://bad-helm-repo.googleapis.com
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-bad-zombie/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-bad_helm_coredns-cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: bad-helm-coredns-coredns
service_name: bad-helm-coredns-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample-coredns-cnf-bad-chart/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-coredns-cnf-source/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
release_name: coredns
service_name: coredns-coredns
helm_chart: stable/coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample-coredns-cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-coredns-cnf2/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns2
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-coredns-cnf3/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns3
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-coredns-cnf4/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns4
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-fragile-state/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
rolling_update_test_tag: 1.6.7
1 change: 0 additions & 1 deletion sample-cnfs/sample-generic-cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: coredns-1609263557
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample-large-cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
1 change: 0 additions & 1 deletion sample-cnfs/sample-local-storage/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
helm_directory: chart
helm_values:
release_name: coredns
service_name: coredns-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample-statefulset-cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
release_name: test

service_name:
helm_repository:
name: bitnami
repo_url: https://charts.bitnami.com/bitnami
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample_bad_signal_handling/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: envoy
service_name: envoy
1 change: 0 additions & 1 deletion sample-cnfs/sample_coredns_bad_liveness/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: bad-liveness
service_name: bad-liveness-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample_coredns_hardcoded_ips/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample_coredns_protected/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns --set imageCredentials.registry=https://index.docker.io/v1/ --set imageCredentials.username=$PROTECTED_DOCKERHUB_USERNAME --set imageCredentials.password=$PROTECTED_DOCKERHUB_PASSWORD --set imageCredentials.email=$PROTECTED_DOCKERHUB_EMAIL --set image.repository=$PROTECTED_IMAGE_REPO
service_name: coredns-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample_envoy_slow_startup/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: envoy
service_name: envoy
1 change: 0 additions & 1 deletion sample-cnfs/sample_good_signal_handling/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: envoy
service_name: envoy
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
release_name: jenkins
service_name: jenkins
helm_repository:
name: jenkins
repo_url: https://charts.jenkins.io
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample_good_zombie_handling/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: envoy
service_name: envoy
1 change: 0 additions & 1 deletion sample-cnfs/sample_hostport/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ helm_directory: chart
git_clone_url:
install_script: chart
release_name: unifi
service_name: unifi-controller
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample_local_registry/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
container_names:
- name: coredns
rolling_update_test_tag: "1.8.0"
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample_network_loss/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
1 change: 0 additions & 1 deletion sample-cnfs/sample_nodeport/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ helm_directory: chart
git_clone_url:
install_script: chart
release_name: unifi
service_name: unifi-controller
1 change: 0 additions & 1 deletion sample-cnfs/sample_privileged_cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: chart
release_name: privileged-coredns
service_name: privileged-coredns
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
helm_directory: chart
release_name: coredns
service_name: coredns-coredns
helm_repository:
name: stable
repo_url: https://cncf.gitlab.io/stable
Expand Down
1 change: 0 additions & 1 deletion sample-cnfs/sample_secret_env/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: postgresql
release_name: postgresql
service_name: postgresql
1 change: 0 additions & 1 deletion sample-cnfs/sample_secret_env_no_ref/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
helm_directory: postgresql
release_name: postgresql
service_name: postgresql
1 change: 0 additions & 1 deletion sample-cnfs/sample_secret_volume/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ helm_directory: postgresql
git_clone_url:
install_script: chart
release_name: postgresql
service_name: postgresql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ helm_directory: postgresql
git_clone_url:
install_script: chart
release_name: postgresql
service_name: postgresql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
helm_directory: chart
release_name: privileged-coredns
service_name: privileged-coredns-coredns
allowlist_helm_chart_container_names: [coredns]
8 changes: 8 additions & 0 deletions src/tasks/setup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ task "configuration_file_setup" do |_, args|
CNFManager::Points.create_points_yml
end

task "test_config" do |_, args|
if args.named["cfg"]?
puts CNFInstall::Config.parse_cnf_config_from_file(args.named["cfg"].to_s).inspect
else
stdout_failure "cfg parameter needed"
exit 1
end
end
32 changes: 32 additions & 0 deletions src/tasks/utils/cnf_installation/config.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "yaml"
require "../utils.cr"
require "./config_versions/config_v2.cr"

module CNFInstall
module Config

class Config < ConfigV2::Config
end

def self.parse_cnf_config_from_file(path_to_config)
yaml_content = File.read(path_to_config)
config_dir = CNFManager.ensure_cnf_testsuite_dir(path_to_config)
begin
parse_cnf_config_from_yaml(yaml_content, config_dir)
rescue exception
stdout_failure "Error during parsing CNF config on #{path_to_config}"
stdout_failure exception.message
stdout_failure "Please check your config according to the config template."
exit 1
end
end

def self.parse_cnf_config_from_yaml(yaml_content, config_dir)
config = Config.from_yaml(yaml_content)

config.dynamic.initialize_dynamic_properties(config, config_dir)

config
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module CNFInstall
module Config
class ConfigBase
include YAML::Serializable
include YAML::Serializable::Strict
end
end
end
Loading

0 comments on commit f1c5d67

Please sign in to comment.