Skip to content

Commit

Permalink
Feature: CNF Installation (5.1) - test preparation
Browse files Browse the repository at this point in the history
- open_metrics and prometheus_traffic - changed config map naming
- ip_addresses - removed

Refs: #2153
Signed-off-by: barmull [email protected]
  • Loading branch information
barmull committed Oct 2, 2024
1 parent 552616c commit 0021efa
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ jobs:
BRANCH_NAME=${GITHUB_REF#refs/heads/}
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${BRANCH_NAME}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_setup cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~compatibility ~pod_network_latency ~platform ~increase_capacity ~decrease_capacity ~ip_addresses ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~install_script_helm ~helm_chart_valid ~helm_chart_published ~rollback ~secrets_used ~immutable_configmap verbose
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~compatibility ~pod_network_latency ~platform ~increase_capacity ~decrease_capacity ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~install_script_helm ~helm_chart_valid ~helm_chart_published ~rollback ~secrets_used ~immutable_configmap verbose
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand Down Expand Up @@ -555,7 +555,7 @@ jobs:
BRANCH_NAME=${GITHUB_REF#refs/heads/}
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${BRANCH_NAME}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_setup cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~platform ~ip_addresses ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~rollback ~secrets_used ~immutable_configmap ~reasonable_startup_time ~reasonable_image_size verbose
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~platform ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~rollback ~secrets_used ~immutable_configmap ~reasonable_startup_time ~reasonable_image_size verbose
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand Down
11 changes: 0 additions & 11 deletions spec/workload/configuration_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,6 @@ describe CnfTestSuite do
end
end

it "'ip_addresses' should pass when no uncommented ip addresses are found in helm chart source", tags: ["ip_addresses"] do
begin
ShellCmd.cnf_setup("cnf-config=./sample-cnfs/sample-coredns-cnf-source/cnf-testsuite.yml verbose skip_wait_for_install")
result = ShellCmd.run_testsuite("ip_addresses verbose")
result[:status].success?.should be_true
(/(PASSED).*(No IP addresses found)/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("sample_coredns_source_cleanup verbose")
end
end

it "'hardcoded_ip_addresses_in_k8s_runtime_configuration' should fail when a hardcoded ip is found in the K8s configuration", tags: ["ip_addresses"] do
begin
ShellCmd.cnf_setup("cnf-path=sample-cnfs/sample_coredns_hardcoded_ips deploy_with_chart=false")
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/static.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ require "colorize"
require "totem"

desc "Static tests"
task "static", ["liveness", "ip_addresses"] do |_, args|
task "static", ["liveness"] do |_, args|
end

45 changes: 0 additions & 45 deletions src/tasks/workload/configuration.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ rolling_version_change_test_names = ["rolling_update", "rolling_downgrade", "rol
desc "Configuration should be managed in a declarative manner, using ConfigMaps, Operators, or other declarative interfaces."

task "configuration", [
"ip_addresses",
"nodeport_not_used",
"hostport_not_used",
"hardcoded_ip_addresses_in_k8s_runtime_configuration",
Expand Down Expand Up @@ -101,50 +100,6 @@ task "latest_tag" do |t, args|
end
end

desc "Does a search for IP addresses or subnets come back as negative?"
task "ip_addresses" do |t, args|
CNFManager::Task.task_runner(args, task: t) do |args, config|
cdir = FileUtils.pwd()
response = String::Builder.new
helm_chart_path = CNFInstall::Config.get_helm_chart_path(config)
Log.info { "Path: #{helm_chart_path}" }
if File.directory?(helm_chart_path)
# Switch to the helm chart directory
Dir.cd(helm_chart_path)
# Look for all ip addresses that are not comments
Log.for(t.name).info { "current directory: #{ FileUtils.pwd()}" }
# should catch comments (# // or /*) and ignore 0.0.0.0
# note: grep wants * escaped twice
Process.run("grep -r -P '^(?!.+0\.0\.0\.0)(?![[:space:]]*0\.0\.0\.0)(?!#)(?![[:space:]]*#)(?!\/\/)(?![[:space:]]*\/\/)(?!\/\\*)(?![[:space:]]*\/\\*)(.+([0-9]{1,3}[\.]){3}[0-9]{1,3})' --exclude=*.txt", shell: true) do |proc|
while line = proc.output.gets
response << line
VERBOSE_LOGGING.info "#{line}" if check_verbose(args)
end
end
Dir.cd(cdir)
parsed_resp = response.to_s
if parsed_resp.size > 0
response_lines = parsed_resp.split("\n")
stdout_failure("Lines with hard-coded IP addresses:")
response_lines.each do |line|
line_parts = line.split(":")
file_name = line_parts.shift()
matching_line = line_parts.join(":").strip()
stdout_failure(" * In file #{file_name}: #{matching_line}")
end
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Failed, "IP addresses found")
else
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Passed, "No IP addresses found")
end
else
# TODO If no helm chart directory, exit with 0 points
# ADD SKIPPED tag for points.yml to allow for 0 points
Dir.cd(cdir)
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Passed, "No IP addresses found")
end
end
end

desc "Do all cnf images have versioned tags?"
task "versioned_tag", ["install_opa"] do |t, args|
CNFManager::Task.task_runner(args, task: t) do |args,config|
Expand Down
2 changes: 1 addition & 1 deletion tools/curl_install_tester_docker_setup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ from base as ci_test
COPY cnf-testsuite .
RUN ./cnf-testsuite setup verbose
RUN wget https://raw.githubusercontent.com/cnti-testcatalog/testsuite/main/example-cnfs/coredns/cnf-testsuite.yml
RUN ./cnf-testsuite ip_addresses cnf-config=./cnf-testsuite.yml verbose
RUN ./cnf-testsuite ip_addresses cnf-config=./cnf-testsuite.yml verbose ?

0 comments on commit 0021efa

Please sign in to comment.