instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.45k stars 2.44k forks source link

Cannot run specs on github action and on local with docker #2106

Open pramodshinde opened 1 year ago

pramodshinde commented 1 year ago

Summary:

I am running testing cases using GitHub actions

I tried run specs on my local but same issues

Steps to repro on local

Expected behavior:

To run test cases

Actual behavior:

Randomized with seed 54299
found available port: 172.18.0.3:38853
using CHROME driver
Thread: provisioning remote chrome driver
Selenium_Url: http://selenium-hub:4444/wd/hub
Starting web server...........Browser: chrome - 106.0.5249.91
unable to start web server within 15 seconds!
....Failed!
Attempt 1 got error: SeleniumDriverSetup::ServerStartupError
found available port: 172.18.0.3:36975
unable to start web server within 15 seconds!
Starting web server..................Failed!
Attempt 2 got error: SeleniumDriverSetup::ServerStartupError
found available port: 172.18.0.3:34789
unable to start web server within 15 seconds!
Starting web server..................Failed!
Attempt 3 got error: SeleniumDriverSetup::ServerStartupError
Giving up
#<Thread:0x0000557cc54d54d0 /usr/src/app/spec/selenium/test_setup/selenium_driver_setup.rb:92 run> terminated with exception (report_on_exception is true):
/usr/src/app/spec/selenium/test_setup/spec_friendly_web_server.rb:64:in `wait_for_server': SeleniumDriverSetup::ServerStartupError (SeleniumDriverSetup::ServerStartupError)
    from /usr/src/app/spec/selenium/test_setup/spec_friendly_web_server.rb:32:in `block in run'
    from /usr/src/app/spec/support/blank_slate_protection.rb:77:in `disable'
    from /usr/src/app/spec/selenium/test_setup/spec_friendly_web_server.rb:30:in `run'
    from /usr/src/app/spec/selenium/test_setup/selenium_driver_setup.rb:482:in `start_in_process_thin_server'
    from /usr/src/app/spec/selenium/test_setup/selenium_driver_setup.rb:396:in `block in start_webserver'
    from /usr/src/app/spec/selenium/test_setup/selenium_driver_setup.rb:246:in `with_retries'
    from /usr/src/app/spec/selenium/test_setup/selenium_driver_setup.rb:394:in `start_webserver'
    from /usr/src/app/spec/selenium/test_setup/selenium_driver_setup.rb:92:in `block in run'
selenium startup failed: SeleniumDriverSetup::ServerStartupError
exiting :'(

Additional notes:

.github/workflows/ci.yml

jobs:
  test:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:14-alpine
        ports:
          - "5432:5432"
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
        env:
          POSTGRES_DB: postgres
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
      selenium-hub:
        image: selenium/standalone-chrome:latest
        options: --shm-size="2g"
        env:
         SE_NODE_GRID_URL: localhost:4444/wd/hub
        ports:
          - 4444:4444
          - 5901:5900
    env:
      RAILS_ENV: test
      CANVAS_DATABASE_HOST: localhost
      CANVAS_DATABASE_USERNAME: postgres
      POSTGRES_PASSWORD: postgres
      CANVAS_DATABASE_TEST: postgres
      CANVAS_DATABASE_PORT: 5432
      ENCRYPTION_KEY: "123123123123123123123"
      COVERAGE: false
      ENABLE_AXE_SELENIUM: false
    steps:
      #- uses: nanasess/setup-chromedriver@v1
      #- name: Run Browser
      #  run: |
      #    export DISPLAY=:99
      #    chromedriver --url-base=/wd/hub &
      #    sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
      - name: Test Selinum start
        run: |
          curl http://selenium-hub:4444/wd/hub/status
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Create Gemfile.lock
        run: touch Gemfile.lock
      - name: Install Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.7
      - name: Install PostgreSQL
        run: sudo apt-get -yqq install libpq-dev libidn11-dev libldap2-dev libxmlsec1-dev libxml2-dev zlib1g-dev
      - name: Run bundle install
        run: |
          gem install bundler
          bundle config set --local path 'vendor/bundle'
          bundle install --jobs 4 --retry 3
      - name: Gem cache
        id: cache-bundle
        uses: actions/cache@v3
        with:
          path: vendor/bundle
          key: bundle-${{ hashFiles('**/Gemfile.rails61.lock') }}
      - name: Copy config files
        run: |
          cp docker-compose/config/database.yml config/database.yml
          cp docker-compose/config/security.yml config/security.yml
          cp config/selenium.github config/selenium.yml
      - name: Set up database schema
        run: bin/rails db:create db:migrate RAILS_ENV=test
      - name: Run tests
        run: bundle exec rspec spec --exclude-pattern "spec/selenium/**, spec/selenium/**/*_spec.rb, spec/selenium/**/**/*_spec.rb"

Any idea What could be wrong here? Any help on this would be really appreciated.

pramodshinde commented 1 year ago

Hi,

Test cases take over 6 to 7 hours to complete, Also for release 2022-09-28.189 a lot of specs are failing. Are specs up to date and the build is green? How we can verify? What all pre-requisites needed to run specs?

I had to run yarn install and compile assets to get this working, but these steps and specs took a lot of time to execute.

   docker-compose run --rm web ./script/install_assets.sh -c bundle
   docker-compose run --rm web bundle exec rails db:create db:migrate RAILS_ENV=test
   docker-compose run --rm web ./script/install_assets.sh -c yarn
   docker-compose run --rm web ./script/install_assets.sh -c compile