Skip to content

Optimise WikiPage spec

Luke Duncalfe requested to merge ld-wiki_spec into master

What does this MR do?

This MR optimises WikiPage spec which was flagged as a slow test #229654 (closed).

Optimisations

Locally the spec has reduced from ~45s to ~14s.

We used to spend ~35s creating factories, and we now spend ~3s doing this.

Before
[TEST PROF INFO] Factories usage

 Total: 416
 Total top-level: 207
 Total time: 35.2881s
 Total uniq factories: 6

   total   top-level     total time      time per call      top-level time               name

     132         113       29.1420s            0.2208s            25.1820s            project
     132           0        5.5594s            0.0421s             0.0000s          namespace
      92          92        9.8735s            0.1073s             9.8735s          wiki_page
      30           1        1.3980s            0.0466s             0.2216s               user
      29           0        1.1805s            0.0407s             0.0000s               wiki
       1           1        0.0110s            0.0110s             0.0110s            license
After
[TEST PROF INFO] Factories usage

 Total: 116
 Total top-level: 99
 Total time: 3.1782s
 Total uniq factories: 6

   total   top-level     total time      time per call      top-level time               name

      95          84        0.0227s            0.0002s             0.0205s               wiki
      11          11        1.0874s            0.0989s             1.0874s          wiki_page
       4           2        1.7510s            0.4377s             1.2710s            project
       4           0        0.1755s            0.0439s             0.0000s          namespace
       1           1        0.0164s            0.0164s             0.0164s            license
       1           1        0.7830s            0.7830s             0.7830s               user

Considerations

Previously, we were creating a new project for each test, which had the benefit of starting each test with a blank wiki repository. The change to persist the project between tests means we reuse the same wiki repository.

In order to make this safer for this test, I've removed the top-level existing_page let (used for tests of saved wiki pages) as we don't want to encourage the risk of tests modifying data that can persist between groups of tests.

Wiki pages need to have unique titles, and the factory will create a unique title if none is supplied. For tests that rely on specific titles in the test, I've modified these to use a different title for each test (previously they were all test page).

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Luke Duncalfe

Merge request reports

Loading