Running tests is a crucial part of the development process in the gitlab-org/gitlab-ce project. This documentation provides a step-by-step guide on how to set up the environment and execute the test suite efficiently.

Prerequisites

Before running tests, ensure you have the following dependencies installed:

  • Ruby (compatible version as specified in the project’s Gemfile)
  • Node.js and npm (required for JavaScript tests)
  • Git

You should also have the project cloned to your local environment:

git clone https://gitlab.com/gitlab-org/gitlab-ce.git
cd gitlab-ce

Setting Up the Environment

  1. Install Dependencies

    Use Bundler to install Ruby gems and npm to install JavaScript packages:

    bundle install
    npm install
    
  2. Prepare the Database

    Set up the database by executing the following commands:

    bundle exec rake db:create RAILS_ENV=test
    bundle exec rake db:schema:load RAILS_ENV=test
    bundle exec rake db:seed RAILS_ENV=test
    

    This will create the test database and load the schema along with the necessary seed data.

Running Tests

To run the entire test suite, execute the following command:

bundle exec rake

This command runs all the tests defined in the project.

Running Specific Test Suites

If you want to run a specific test suite, you can specify the test type using rake tasks:

  • RSpec Tests: To run RSpec tests, use:

    bundle exec rspec
    
  • Unit Tests: To run unit tests only, use:

    bundle exec rake test
    
  • Feature Tests: For feature tests, run:

    bundle exec rspec spec/features
    

Running Tests with Specific Files or Directories

You may also want to run tests defined in a specific file or directory. Use the following syntax:

bundle exec rspec path/to/your/spec_file.rb

For example, to run tests in a specific spec directory:

bundle exec rspec spec/models

Running JavaScript Tests

JavaScript tests can be executed using npm. To run the JavaScript test suite, execute:

npm test

Continuous Integration (CI) Testing

The project uses GitLab CI/CD for automated testing on code submissions. When pushing changes, tests will automatically run based on the .gitlab-ci.yml configuration.

To trigger CI manually or check the status of your changes, visit the appropriate GitLab repository interface after pushing your code.

Additional Configuration

If you need to set up a test environment for specific configurations, you can customize it using environment variables or configuration files. Refer to the project documentation for specifics about configuration management.

Cleanup After Testing

Once you are finished testing, you might want to clean up any test data or database changes. You can drop the test database using:

bundle exec rake db:drop RAILS_ENV=test

Conclusion

By following the steps above, you can run tests for the gitlab-org/gitlab-ce project effectively. Ensure to keep your environment up to date according to the project’s requirements for the smooth running of tests.

Reference: The above instructions are based on the setup guidelines typically applicable in Ruby on Rails projects and follow the conventions used in the gitlab-org/gitlab-ce repository.