Skip to content

Remove use of let_it_be in spec

Heinrich Lee Yu requested to merge 369060-fix-let-it-be-specs-order into master

What does this MR do and why?

This prevents breaking of let_it_be for all specs that run after this one. This is configuring the adapter to be a no-op so all subsequent specs that use let_it_be / before_all are not creating and rolling back transactions properly.

We do not really need let_it_be here anyway since we're just instantiating a struct.

For the specific failure in the issue, it was due to reindex_action_spec.rb calling swapout_view_for_table(:postgres_indexes) which when not rolled back properly, will cause postgres_index_bloat_estimate_spec.rb to fail.

Reproducing locally

bin/rspec spec/lib/gitlab/graphql/type_name_deprecations_spec.rb spec/lib/gitlab/database/reindexing/reindex_action_spec.rb spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb -r spec_helper

Note that if you do reproduce the failure, you'd have to do this in psql to restore the DB:

\c gitlabhq_test

DROP TABLE postgres_indexes;

CREATE VIEW postgres_indexes AS
SELECT (pg_namespace.nspname::text || '.'::text) || i.relname::text AS identifier,
  pg_index.indexrelid,
  pg_namespace.nspname AS schema,
  i.relname AS name,
  pg_indexes.tablename,
  a.amname AS type,
  pg_index.indisunique AS "unique",
  pg_index.indisvalid AS valid_index,
  i.relispartition AS partitioned,
  pg_index.indisexclusion AS exclusion,
  pg_index.indexprs IS NOT NULL AS expression,
  pg_index.indpred IS NOT NULL AS partial,
  pg_indexes.indexdef AS definition,
  pg_relation_size(i.oid::regclass) AS ondisk_size_bytes
FROM pg_index
  JOIN pg_class i ON i.oid = pg_index.indexrelid
  JOIN pg_namespace ON i.relnamespace = pg_namespace.oid
  JOIN pg_indexes ON i.relname = pg_indexes.indexname AND pg_namespace.nspname = pg_indexes.schemaname
  JOIN pg_am a ON i.relam = a.oid
WHERE pg_namespace.nspname <> 'pg_catalog'::name AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name]));

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #369060 (closed)

Edited by Heinrich Lee Yu

Merge request reports

Loading