summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable Timecop safe mode32004-use-timecop-safe-modeRémy Coutable2017-08-111-0/+1
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Reset only migration models36052-reset-only-migration-modelsLin Jen-Shin2017-08-071-2/+2
| | | | | | | | | | | | | | | | | So that we could make sure migration tests could run even if geo is not setup in EE. This is because we have a model like this: ``` ruby class Geo::BaseRegistry < ActiveRecord::Base def self.connection raise 'Geo secondary database is not configured' unless Gitlab::Geo.geo_database_configured? super end end ```
* Don't send rejection mails for all auto-generated mails28472-ignore-auto-generated-mailsLin Jen-Shin2017-08-031-1/+5
| | | | Also make it easier to have mailer helper
* Remove events column from notification settings33620-remove-events-from-notification_settingsSean McGivern2017-07-311-0/+4
| | | | | This was migrated to separate columns in 9.4, and now just needs to be removed for real.
* Ensure Gitlab::Application.routes.default_url_options are set correctly in ↵Rémy Coutable2017-07-281-0/+1
| | | | | | Capybara + :js specs Signed-off-by: Rémy Coutable <remy@rymai.me>
* Update shoulda-matchers gem to 3.1.2Dmitriy Zaporozhets2017-07-241-0/+7
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* Update Prometheus gem to version that explicitly calls `munmap`Paweł Chojnacki2017-07-191-1/+0
|
* Enable all feature flags by default in specsbvl-enable-features-in-testBob Van Landuyt2017-07-131-0/+3
| | | | | | | | | Otherwise some features would go untested in non-specific contexts I did need to disable the `gitlab_git_diff_size_limit_increase`-feature in some specs since we depend on diffs being expandable while the file we are testing on is smaller than the increased limit.
* Replace 'browse_files.feature' spinach test with an rspec analogblackst0ne2017-07-121-0/+5
|
* Support multiple Redis instances based on queue typePaul Charlton2017-07-111-5/+15
|
* Include new URL helpers retroactively into includers of Gitlab::Routingdm-fix-project-path-helpers-productionDouwe Maan2017-07-071-1/+1
|
* Create and use project path helpers that only need a project, no namespaceDouwe Maan2017-07-051-1/+1
|
* Include Devise::Test::IntegrationHelpers for all feature specsRobert Speicher2017-06-191-0/+1
|
* Make spec/spec_helper consistent with EE by including a :routing typesh-fix-spec-helper-ee-consistencyStan Hu2017-06-141-0/+1
|
* Fix migrations testing support RSpec hooks orderfix/gb/fix-migrations-testing-support-hooks-orderGrzegorz Bizon2017-06-131-9/+7
|
* Merge branch 'retry-specs' into 'master'Robert Speicher2017-06-121-3/+2
|\ | | | | | | | | Attempts to run RSpec tests twice (1 retry) See merge request !12066
| * Attempts to run RSpec tests twice (1 retry)retry-specsRémy Coutable2017-06-121-3/+2
| | | | | | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* | Use :request_store hooks on specsuse-request-store-helper-instead-actual-codeOswaldo Ferreira2017-06-091-0/+9
|/
* Merge branch 'feature/gb/migrate-pipeline-stages' into 'master'Kamil Trzciński2017-06-071-0/+12
|\ | | | | | | | | Migrate pipeline stages in the database See merge request !11714
| * Merge branch 'master' into feature/gb/migrate-pipeline-stagesGrzegorz Bizon2017-06-051-0/+11
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (524 commits) Improve user experience around slash commands in instant comments Fix LFS timeouts when trying to save large files retryable? is now available for CommitStatus Resolve "Documentation of `.gitlab-ci.yml` states incorrect example for variables" Fix test failures Add slugify project path to CI enviroment variables Fixed typo: craeted -> created 32118 Make New environment empty state btn lowercase Expose import_status in Projects API 32832 Remove overflow from comment form for confidential issues and vertically aligns confidential issue icon Fix test failures Allow manual bypass of auto_sign_in_with_provider Fix keys seed Allow users to be hard-deleted from the API fixup some classnames and media queries Enable the Style/PreferredHashMethods cop Lint our factories creation in addition to their build Don’t schedule workers from inside transactions Allow scheduling from after_commit hooks Forbid Sidekiq scheduling in transactions ... Conflicts: db/schema.rb spec/spec_helper.rb
| * | Calculate previous migration version in specs supportGrzegorz Bizon2017-06-051-3/+3
| | | | | | | | | | | | | | | | | | This makes it possible to test migration on the schema this migration was written for, without a need to specify a previous schema version manually.
| * | Reorder pipeline stages-related migrationsGrzegorz Bizon2017-05-261-5/+7
| | |
| * | Add pipeline stages post deployment migrationGrzegorz Bizon2017-05-261-2/+2
| | |
| * | Add migrations helpers to simplify writing migration specsGrzegorz Bizon2017-05-261-3/+3
| | |
| * | Make migration specs by using migrator in around hookGrzegorz Bizon2017-05-261-1/+1
| | |
| * | Simplify migrations for specific database schemaGrzegorz Bizon2017-05-251-0/+10
| | |
* | | Move Prometheus presentation logic to PrometheusTextPawel Chojnacki2017-06-021-0/+1
| |/ |/| | | | | | | | | | | | | + Use NullMetrics to mock metrics when unused + Use method_missing in NullMetrics mocking + Update prometheus gem to version that correctly uses transitive dependencies + Ensure correct folders are used in Multiprocess prometheus client tests. + rename Sessions controller's metric
* | Move rainbow monkey patch to String to spec_helperGabriel Mazetto2017-05-311-0/+3
| |
* | Merge branch 'rework-authorizations-performance' into 'master'Douwe Maan2017-05-291-0/+8
|\ \ | |/ |/| | | | | Rework project authorizations and nested groups for better performance See merge request !10885
| * Hide nested group UI/API support for MySQLYorick Peterse2017-05-171-1/+1
| | | | | | | | | | | | This hides/disables some UI elements and API parameters related to nested groups when MySQL is used, since nested groups are not supported for MySQL.
| * Use CTEs for nested groups and authorizationsYorick Peterse2017-05-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces the usage of Common Table Expressions (CTEs) to efficiently retrieve nested group hierarchies, without having to rely on the "routes" table (which is an _incredibly_ inefficient way of getting the data). This requires a patch to ActiveRecord (found in the added initializer) to work properly as ActiveRecord doesn't support WITH statements properly out of the box. Unfortunately MySQL provides no efficient way of getting nested groups. For example, the old routes setup could easily take 5-10 seconds depending on the amount of "routes" in a database. Providing vastly different logic for both MySQL and PostgreSQL will negatively impact the development process. Because of this the various nested groups related methods return empty relations when used in combination with MySQL. For project authorizations the logic is split up into two classes: * Gitlab::ProjectAuthorizations::WithNestedGroups * Gitlab::ProjectAuthorizations::WithoutNestedGroups Both classes get the fresh project authorizations (= as they should be in the "project_authorizations" table), including nested groups if PostgreSQL is used. The logic of these two classes is quite different apart from their public interface. This complicates development a bit, but unfortunately there is no way around this. This commit also introduces Gitlab::GroupHierarchy. This class can be used to get the ancestors and descendants of a base relation, or both by using a UNION. This in turn is used by methods such as: * Namespace#ancestors * Namespace#descendants * User#all_expanded_groups Again this class relies on CTEs and thus only works on PostgreSQL. The Namespace methods will return an empty relation when MySQL is used, while User#all_expanded_groups will return only the groups a user is a direct member of. Performance wise the impact is quite large. For example, on GitLab.com Namespace#descendants used to take around 580 ms to retrieve data for a particular user. Using CTEs we are able to reduce this down to roughly 1 millisecond, returning the exact same data. == On The Fly Refreshing Refreshing of authorizations on the fly (= when users.authorized_projects_populated was not set) is removed with this commit. This simplifies the code, and ensures any queries used for authorizations are not mutated because they are executed in a Rails scope (e.g. Project.visible_to_user). This commit includes a migration to schedule refreshing authorizations for all users, ensuring all of them have their authorizations in place. Said migration schedules users in batches of 5000, with 5 minutes between every batch to smear the load around a bit. == Spec Changes This commit also introduces some changes to various specs. For example, some specs for ProjectTeam assumed that creating a personal project would _not_ lead to the owner having access, which is incorrect. Because we also no longer refresh authorizations on the fly for new users some code had to be added to the "empty_project" factory. This chunk of code ensures that the owner's permissions are refreshed after creating the project, something that is normally done in Projects::CreateService.
* | Use wait_for_requests to wait all JS requestwait-for-ajax-handling-all-js-requestsOswaldo Ferreira2017-05-221-1/+0
| |
* | Enable RSpec profiling only if RSPEC_PROFILING_POSTGRES_URL is not empty31933-improve-rspec-profiling-enablingRémy Coutable2017-05-191-1/+1
|/ | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Resolve "rspec_profiling is enabled for MySQL"Rémy Coutable2017-04-281-2/+3
|
* Allow to enable `rspec_profiling` for a branch on the CI30907-allow-to-enable-rspec-profile-for-a-given-branchRémy Coutable2017-04-131-2/+8
| | | | | | | `rspec_profiling` will be enabled if the branch name includes `rspec-profile`. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Setup and run a Gitaly server for testing if GitalyClient is enabledgitaly-testingAlejandro Rodríguez2017-04-111-0/+4
|
* When on CI, enable RSpec profiling for `master` onlyRémy Coutable2017-03-241-1/+2
| | | | | | We don't actually need to monitor RSpec for all our branches. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Only include WaitForAjax for :js specsRémy Coutable2017-03-221-1/+1
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Introduce a new middleware for the test environment that can block requestsRémy Coutable2017-03-221-0/+1
| | | | | | | | | | | | The idea is that after each feature spec example, we block all incoming requests at the Rack level, go to the 'about:blank' page, and wait until the current requests reach 0. This should solve the problem where a request would end after database cleaner performed the database truncation. The problem was that a GET request can still lead to records creation (e.g. namespaces or routes). Signed-off-by: Rémy Coutable <remy@rymai.me>
* Retry only on feature specs that use JS, on CI29242-fix-api-specs-potential-weird-failures-on-retriesRémy Coutable2017-03-131-0/+7
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Implement `json_response` as a `let` variableRémy Coutable2017-03-131-0/+6
| | | | | | | | | | | | | | | This is not a good idea to memoize `json_response` using an instance variable because `rspec-retry` doesn't clear instance variables on retries, only `let` variables. This will avoid issues where retries would fail on a different line that the original failure, blurrying what's the real failure. Also, automatically add api: true to specs under /spec/requests/(ci/)?api/, and include JsonHelpers in controller, request and API specs. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Shave spec/features/issues/filtered_search/dropdown_label_spec.rb from 10 ↵27564-shave-dropdown-label-search-spec-durationRémy Coutable2017-02-031-0/+1
| | | | | | | | | | | | | | | minutes to 1.5 minutes - Don't use `sleep` (most of the time was wasted by that) - Expect some elements to be visible instead: capybara is smart enough to retry a few times if it cannot find an element - See https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends - Don't create unneccessary DB records - Group some examples together to shave some setup time (where it makes sense) Signed-off-by: Rémy Coutable <remy@rymai.me>
* Add the rspec_profiling gem and documentation to the GitLab development ↵23034-enable-rspec-profilingNick Thomas2017-01-271-0/+4
| | | | environment
* Merge branch 'refresh-authorizations-fork-join' into 'master' Douwe Maan2017-01-251-1/+0
|\ | | | | | | | | | | | | Fix race conditions for AuthorizedProjectsWorker Closes #26194 and #26310 See merge request !8701
| * Fix race conditions for AuthorizedProjectsWorkerrefresh-authorizations-fork-joinYorick Peterse2017-01-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were two cases that could be problematic: 1. Because sometimes AuthorizedProjectsWorker would be scheduled in a transaction it was possible for a job to run/complete before a COMMIT; resulting in it either producing an error, or producing no new data. 2. When scheduling jobs the code would not wait until completion. This could lead to a user creating a project and then immediately trying to push to it. Usually this will work fine, but given enough load it might take a few seconds before a user has access. The first one is problematic, the second one is mostly just annoying (but annoying enough to warrant a solution). This commit changes two things to deal with this: 1. Sidekiq scheduling now takes places after a COMMIT, this is ensured by scheduling using Rails' after_commit hook instead of doing so in an arbitrary method. 2. When scheduling jobs the calling thread now waits for all jobs to complete. Solution 2 requires tracking of job completions. Sidekiq provides a way to find a job by its ID, but this involves scanning over the entire queue; something that is very in-efficient for large queues. As such a more efficient solution is necessary. There are two main Gems that can do this in a more efficient manner: * sidekiq-status * sidekiq_status No, this is not a joke. Both Gems do a similar thing (but slightly different), and the only difference in their name is a dash vs an underscore. Both Gems however provide far more than just checking if a job has been completed, and both have their problems. sidekiq-status does not appear to be actively maintained, with the last release being in 2015. It also has some issues during testing as API calls are not stubbed in any way. sidekiq_status on the other hand does not appear to be very popular, and introduces a similar amount of code. Because of this I opted to write a simple home grown solution. After all, all we need is storing a job ID somewhere so we can efficiently look it up; we don't need extra web UIs (as provided by sidekiq-status) or complex APIs to update progress, etc. This is where Gitlab::SidekiqStatus comes in handy. This namespace contains some code used for tracking, removing, and looking up job IDs; all without having to scan over an entire queue. Data is removed explicitly, but also expires automatically just in case. Using this API we can now schedule jobs in a fork-join like manner: we schedule the jobs in Sidekiq, process them in parallel, then wait for completion. By using Sidekiq we can leverage all the benefits such as being able to scale across multiple cores and hosts, retrying failed jobs, etc. The one downside is that we need to make sure we can deal with unexpected increases in job processing timings. To deal with this the class Gitlab::JobWaiter (used for waiting for jobs to complete) will only wait a number of seconds (30 by default). Once this timeout is reached it will simply return. For GitLab.com almost all AuthorizedProjectWorker jobs complete in seconds, only very rarely do we spike to job timings of around a minute. These in turn seem to be the result of external factors (e.g. deploys), in which case a user is most likely not able to use the system anyway. In short, this new solution should ensure that jobs are processed properly and that in almost all cases a user has access to their resources whenever they need to have access.
* | Revert "Merge branch 'revert-9cac0317' into 'master' "Grzegorz Bizon2017-01-231-0/+1
|/ | | | | This reverts commit c20934869f7dc8cfbdbafb6ecb7b1305452c9e8a, reversing changes made to 4b7ec44b91e0571d209c790d54947ba1756dac0e.
* Revert "Merge branch 'dont-persist-application-settings-in-test-env' into ↵Grzegorz Bizon2017-01-211-1/+0
| | | | | 'master'" This reverts merge request !8573
* Don't persist ApplicationSetting in test envdont-persist-application-settings-in-test-envRémy Coutable2017-01-151-0/+1
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Pass commit data to ProcessCommitWorkerprocess-commit-worker-improvementsYorick Peterse2016-12-011-0/+4
| | | | | | | | | | | By passing commit data to this worker we remove the need for querying the Git repository for every job. This in turn reduces the time spent processing each job. The migration included migrates jobs from the old format to the new format. For this to work properly it requires downtime as otherwise workers may start producing errors until they're using a newer version of the worker code.
* Only include EmailHelpers in mailer specs and specs using themrs-include-emailhelpersRobert Speicher2016-12-011-1/+1
|