diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-08-17 00:11:00 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-08-17 12:19:01 +0800 |
commit | 2efd5c0b63eb3b86354988cf0f47a0ca83e52d3e (patch) | |
tree | 311936d1f5130966939a484787fe5c569b36b3b2 /qa | |
parent | bba7504438d5cc4ea98500754c8d0a8b9ff1fc42 (diff) | |
download | gitlab-ce-2efd5c0b63eb3b86354988cf0f47a0ca83e52d3e.tar.gz |
Fill variable text with JS directly to speed up49179-fill-with-js-directly-qa
It's too slow to use `set(value)`, often timing out.
Filling with JS is much faster for longer text, especially
when the key size is larger than 8192.
Before this patch:
```
Top 3 slowest examples (256.83 seconds, 89.4% of total time):
cloning code using a deploy key user sets up a deploy key with QA::Runtime::Key::RSA(8192) to clone code using pipelines
161.26 seconds ./qa/specs/features/project/deploy_key_clone_spec.rb:42
cloning code using a deploy key user sets up a deploy key with QA::Runtime::Key::ECDSA(521) to clone code using pipelines
47.79 seconds ./qa/specs/features/project/deploy_key_clone_spec.rb:42
cloning code using a deploy key user sets up a deploy key with QA::Runtime::Key::ED25519() to clone code using pipelines
47.79 seconds ./qa/specs/features/project/deploy_key_clone_spec.rb:42
```
Note that 161.26 was timed out. So it would actually take longer if
it could ever complete. After patch:
```
Top 3 slowest examples (166.72 seconds, 83.8% of total time):
cloning code using a deploy key user sets up a deploy key with QA::Runtime::Key::RSA(8192) to clone code using pipelines
83.66 seconds ./qa/specs/features/project/deploy_key_clone_spec.rb:42
cloning code using a deploy key user sets up a deploy key with QA::Runtime::Key::ECDSA(521) to clone code using pipelines
42.78 seconds ./qa/specs/features/project/deploy_key_clone_spec.rb:42
cloning code using a deploy key user sets up a deploy key with QA::Runtime::Key::ED25519() to clone code using pipelines
40.27 seconds ./qa/specs/features/project/deploy_key_clone_spec.rb:42
```
Not that faster for smaller keys, but it's much faster for RSA 8192
(2 times faster). This was inspired from:
https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217
Where it's clearing the field by filling an empty string. Here we
do the same for the exact value we want to fill.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/page/project/settings/secret_variables.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/qa/qa/page/project/settings/secret_variables.rb b/qa/qa/page/project/settings/secret_variables.rb index d2f5d5a9060..937ae6797c8 100644 --- a/qa/qa/page/project/settings/secret_variables.rb +++ b/qa/qa/page/project/settings/secret_variables.rb @@ -23,7 +23,13 @@ module QA # After we fill the key, JS would generate another field so # we need to use the same index to find the corresponding one. keys[index].set(key) - all_elements(:ci_variable_input_value)[index].set(value) + node = all_elements(:ci_variable_input_value)[index] + + # Simply run `node.set(value)` is too slow for long text here, + # so we need to run JavaScript directly to set the value. + # The code was inspired from: + # https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217 + execute_script("arguments[0].value = #{value.to_json}", node) end def save_variables |