diff --git a/apps/dashboard/app/models/hpc_module.rb b/apps/dashboard/app/models/hpc_module.rb index 3029614266..3bccf8a388 100644 --- a/apps/dashboard/app/models/hpc_module.rb +++ b/apps/dashboard/app/models/hpc_module.rb @@ -10,9 +10,9 @@ def all(cluster) begin JSON.parse(File.read(file)).map do |name, spider_output| spider_output.map do |_, mod| - HpcModule.new(name, version: mod['Version']) + HpcModule.new(name, version: mod['Version'], hidden: mod['hidden']) end - end.flatten.uniq + end.flatten.uniq.reject(&:hidden?) rescue StandardError => e Rails.logger.warn("Did not read #{file} correctly because #{e.class}:#{e.message}") [] @@ -31,11 +31,13 @@ def all_versions(module_name) end end - attr_reader :name, :version + attr_reader :name, :version, :hidden + alias hidden? hidden - def initialize(name, version: nil) + def initialize(name, version: nil, hidden: false) @name = name @version = version.to_s if version + @hidden = hidden end def to_s diff --git a/apps/dashboard/test/application_system_test_case.rb b/apps/dashboard/test/application_system_test_case.rb index de58d59d39..726e0cac50 100644 --- a/apps/dashboard/test/application_system_test_case.rb +++ b/apps/dashboard/test/application_system_test_case.rb @@ -14,7 +14,11 @@ def find_option_style(ele, opt) end def find_all_options(ele, opt) - all("##{bc_ele_id(ele)} option[value='#{opt}']") + if opt.nil? + all("##{bc_ele_id(ele)} option") + else + all("##{bc_ele_id(ele)} option[value='#{opt}']") + end end def find_max(ele) diff --git a/apps/dashboard/test/models/hpc_module_test.rb b/apps/dashboard/test/models/hpc_module_test.rb index 94490890f4..6a0cd0727d 100644 --- a/apps/dashboard/test/models/hpc_module_test.rb +++ b/apps/dashboard/test/models/hpc_module_test.rb @@ -25,12 +25,13 @@ def fixture_dir end end - test 'all versions is corrrect, sorted and unique' do + test 'all_versions is corrrect, sorted and unique' do stub_sys_apps with_modified_env({ OOD_MODULE_FILE_DIR: fixture_dir }) do + # "app_jupyter/1.2.21" in oakley.json is hidden expected = [ 'app_jupyter/3.1.18', 'app_jupyter/3.0.17', 'app_jupyter/2.3.2', 'app_jupyter/2.2.10', - 'app_jupyter/1.2.21', 'app_jupyter/1.2.16', 'app_jupyter/0.35.6' + 'app_jupyter/1.2.21', 'app_jupyter/0.35.6' ] assert_equal(expected, HpcModule.all_versions('app_jupyter').map(&:to_s)) end @@ -63,4 +64,16 @@ def fixture_dir assert !m.default? assert_equal m.version, '9001' # we gave an int, got back a string end + + test 'hidden modules are filtered' do + stub_sys_apps + with_modified_env({ OOD_MODULE_FILE_DIR: fixture_dir }) do + # "mkl/.2019.0.5" in oakley.json is hidden + expected = [ + 'mkl/2019.0.5', 'mkl/2019.0.3', 'mkl/2018.0.3', 'mkl/2017.0.7', + 'mkl/2017.0.4', 'mkl/2017.0.2', 'mkl/11.3.3' + ] + assert_equal(expected, HpcModule.all_versions('mkl').map(&:to_s)) + end + end end diff --git a/apps/dashboard/test/system/batch_connect_test.rb b/apps/dashboard/test/system/batch_connect_test.rb index 4a474ced61..b315c7b82e 100644 --- a/apps/dashboard/test/system/batch_connect_test.rb +++ b/apps/dashboard/test/system/batch_connect_test.rb @@ -614,7 +614,6 @@ def stub_scontrol(dir, cluster) assert_equal 'owens', find_value('cluster') # versions not available on owens assert_equal 'display: none;', find_option_style('auto_modules_app_jupyter', 'app_jupyter/3.1.18') - assert_equal 'display: none;', find_option_style('auto_modules_app_jupyter', 'app_jupyter/1.2.16') assert_equal 'display: none;', find_option_style('auto_modules_app_jupyter', 'app_jupyter/0.35.6') assert_equal 'display: none;', find_option_style('auto_modules_intel', 'intel/18.0.4') @@ -622,7 +621,6 @@ def stub_scontrol(dir, cluster) select('oakley', from: bc_ele_id('cluster')) assert_equal 'app_jupyter', find_value('auto_modules_app_jupyter') assert_equal '', find_option_style('auto_modules_app_jupyter', 'app_jupyter/3.1.18') - assert_equal '', find_option_style('auto_modules_app_jupyter', 'app_jupyter/1.2.16') assert_equal '', find_option_style('auto_modules_app_jupyter', 'app_jupyter/0.35.6') # and lots of intel versions aren't @@ -653,6 +651,29 @@ def stub_scontrol(dir, cluster) end end + test 'auto generated modules hide hidden modules' do + with_modified_env({ OOD_MODULE_FILE_DIR: 'test/fixtures/modules' }) do + visit new_batch_connect_session_context_url('sys/bc_jupyter') + + # defaults, note that intel doesn't show the default version + assert_equal 'app_jupyter', find_value('auto_modules_app_jupyter') + assert_equal 'intel/2021.3.0', find_value('auto_modules_intel') + assert_equal 'owens', find_value('cluster') + + # oakley has the hidden intel module 'intel/2021.4.0' + select('oakley', from: bc_ele_id('cluster')) + + actual_options = find_all_options('auto_modules_intel', nil).map(&:text) + + # '2021.4.0' is not listed here. + expected_options = [ + '2021.3.0', '19.1.3', '19.0.5', '19.0.3', '18.0.4', '18.0.3', '18.0.2', + '18.0.0', '17.0.7', '17.0.5', '17.0.2', '16.0.8', '16.0.3' + ] + assert_equal(expected_options, actual_options) + end + end + test 'auto accounts are cluster aware' do Dir.mktmpdir do |dir| "#{dir}/app".tap { |d| Dir.mkdir(d) }