From ad0a5850d5f9a12758a0d61f8fdc38cc61cf6fc4 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Mon, 1 Apr 2024 18:16:36 +0900 Subject: [PATCH] arm-stable chrome --- .rubocop_todo.yml | 2 +- lib/kaiser/cli.rb | 16 +++++++++++++++- spec/cli_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 774cecaa..797b66bf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -43,7 +43,7 @@ Lint/ConstantDefinitionInBlock: # Offense count: 11 # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: - Max: 57 + Max: 58 # Offense count: 7 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. diff --git a/lib/kaiser/cli.rb b/lib/kaiser/cli.rb index dd9cd846..4f616c1f 100644 --- a/lib/kaiser/cli.rb +++ b/lib/kaiser/cli.rb @@ -524,6 +524,19 @@ def prepare_cert_volume! end end + def selenium_node_image + return ENV['OVERRIDE_SELENIUM_NODE_IMAGE'] unless ENV['OVERRIDE_SELENIUM_NODE_IMAGE'].nil? + + if RUBY_PLATFORM.start_with?('arm64') || RUBY_PLATFORM.start_with?('aarch64') + # use the seleniarm image because its more stable in arm procs + # somehow the x64 image does not do well under qemu under arm + return 'seleniarm/standalone-chromium' + end + + # default to x64 image + 'selenium/standalone-chrome-debug' + end + def ensure_setup ensure_env @@ -544,9 +557,10 @@ def ensure_setup Config.config[:shared_names][:chrome], "docker run -d -p 5900:5900 + --shm-size='2g' --name #{Config.config[:shared_names][:chrome]} --network #{Config.config[:networkname]} - selenium/standalone-chrome-debug" + #{selenium_node_image}" ) run_if_dead( Config.config[:shared_names][:nginx], diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 9cc92924..799a3fdf 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -46,4 +46,24 @@ expect(cli.send(:db_image)).to eq('postgres:alpine') end end + + describe '#selenium_node_image' do + it 'for x86 machines returns normal selenium' do + cli = Kaiser::Cli.new + stub_const('RUBY_PLATFORM', 'x86_64-linux') + expect(cli.selenium_node_image).to eq('selenium/standalone-chrome-debug') + end + + it 'for arm machines on mac' do + cli = Kaiser::Cli.new + stub_const('RUBY_PLATFORM', 'arm64-darwin23') + expect(cli.selenium_node_image).to eq('seleniarm/standalone-chromium') + end + + it 'for arm machines on linux' do + cli = Kaiser::Cli.new + stub_const('RUBY_PLATFORM', 'arch64-linux') + expect(cli.selenium_node_image).to eq('seleniarm/standalone-chromium') + end + end end