From f8641cddebb75e0843131b406452ce91f76a90ef Mon Sep 17 00:00:00 2001 From: Qiaoling Tang <38000637+QiaolingTang@users.noreply.github.com> Date: Mon, 1 Mar 2021 13:34:48 +0800 Subject: [PATCH] add env vars for logging to set catsrc and channel (#1870) --- features/step_definitions/logging.rb | 32 +++++++++++++++++---------- features/test/logging_metrics.feature | 2 +- lib/environment.rb | 22 ++++++++++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/features/step_definitions/logging.rb b/features/step_definitions/logging.rb index 2d20931b29..8b42ca2bc3 100644 --- a/features/step_definitions/logging.rb +++ b/features/step_definitions/logging.rb @@ -326,26 +326,34 @@ Given /^logging channel name is stored in the#{OPT_SYM} clipboard$/ do | cb_name | cb_name = 'logging_channel_name' unless cb_name - version = cluster_version('version').version.split('-')[0].split('.').take(2).join('.') - case version - when '4.1' - cb[cb_name] = "preview" - when '4.7' - cb[cb_name] = "5.0" + if env.logging_channel_name.empty? + version = cluster_version('version').version.split('-')[0].split('.').take(2).join('.') + case version + when '4.1' + cb[cb_name] = "preview" + when '4.7' + cb[cb_name] = "5.0" + else + cb[cb_name] = version + end else - cb[cb_name] = version + cb[cb_name] = env.logging_channel_name end end Given /^#{QUOTED} packagemanifest's catalog source name is stored in the#{OPT_SYM} clipboard$/ do |packagemanifest, cb_name| cb_name = "catsrc_name" unless cb_name project("openshift-marketplace") - if catalog_source("qe-app-registry").exists? - cb[cb_name] = "qe-app-registry" + if env.logging_catsrc.empty? + if catalog_source("qe-app-registry").exists? + cb[cb_name] = "qe-app-registry" + else + @result = admin.cli_exec(:get, resource: 'packagemanifest', resource_name: packagemanifest, n: 'openshift-marketplace', o: 'yaml') + raise "Unable to get catalog source name" unless @result[:success] + cb[cb_name] = @result[:parsed]['status']['catalogSource'] + end else - @result = admin.cli_exec(:get, resource: 'packagemanifest', resource_name: packagemanifest, n: 'openshift-marketplace', o: 'yaml') - raise "Unable to get catalog source name" unless @result[:success] - cb[cb_name] = @result[:parsed]['status']['catalogSource'] + cb[cb_name] = env.logging_catsrc end end diff --git a/features/test/logging_metrics.feature b/features/test/logging_metrics.feature index f98c754674..3b69bff22a 100644 --- a/features/test/logging_metrics.feature +++ b/features/test/logging_metrics.feature @@ -11,4 +11,4 @@ Feature: test logging and metrics related steps Given I obtain test data file "logging/clusterlogging/example.yaml" Given I create clusterlogging instance with: | crd_yaml | example.yaml | - | remove_logging_pods | true | + | remove_logging_pods | true | diff --git a/lib/environment.rb b/lib/environment.rb index d6b7288c82..69ca6c8f51 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -224,6 +224,28 @@ def authentication_url return @authentication_url end + def logging_channel_name + unless @logging_channel_name + if opts[:logging_channel_name] + @logging_channel_name = opts[:logging_channel_name] + else + @logging_channel_name = '' + end + end + return @logging_channel_name + end + + def logging_catsrc + unless @logging_catsrc + if opts[:logging_catsrc] + @logging_catsrc = opts[:logging_catsrc] + else + @logging_catsrc = '' + end + end + return @logging_catsrc + end + # naming scheme is https://logs..openshift.com for Online # for OCP it's https://logs..openshift.com def logging_console_url