Page MenuHomePhabricator

Use Catalyst API to deploy Ultraviolet in CI for E2E testing
Closed, ResolvedPublic

Description

Opening a Phab task for this as recommended by SDunlap (discussion on wikitech:Talk:Catalyst).

As a userscript developer, I want to be able to spin up a MW instance so that I can have my userscript undergo E2E testing in CI.

What we would like to be able to do:

  • create a Catalyst/Patchdemo (not sure which would be more appropriate) instance in CI
    • have the CI automatically tear down the instance as well when tests finish running
  • have the built userscript deployed directly to the instance if possible (maybe through some sort of config option that can deploy the script to a page on the wiki?)
    • or just deploy it through mediawiki API
  • some way to get a username/password pair for Playwright to log in
    • a sysop account to test features when necessary
  • some way to get the wiki seeded with some test edits/some "vandal" accounts so that they can be reverted/blocked as accordingly by the tests

Interested to hear thoughts on this and whether this usecase could be supported as of now.

Event Timeline

Hi @Sportzpikachu thanks for this!

We can work together to get you set up with what you need. But we're working on something to ensure this is stable at the moment (c.f. T417304). Once that work is complete we can get you a token to use in CI.

How is ultraviolet deployed? Would we need to modify our charts for launching MediaWiki? Or do you only need a working MediaWiki and can run everything else from GitLab CI?

Thanks for your response! Right now we just deploy through action API+REST API with a CD script (which has an approval flow that we could skip for the CI test probably), since UV is just a normal userscript page onwiki. We won't deploy any extensions - however it would be nice to have the extensions that are on enwiki so that we can test features such as CheckUser, pending changes, etc. I don't think we would need a chart update for this - normal working MW instance would probably be good enough.

However if there is a declarative config option to preload pages on-wiki, that would be most helpful. Additionally if we could also preload gadgets on-wiki as well since we have a few integrations (e.g. RTRC) that would be nice to have. But we could always just use action API for these as well.

Thanks @Sportzpikachu let's try using the default chart for you all: that should let you set up MediaWiki and CheckUser pretty easily.

We need to get you a token. The token is limited to 3 environments at a time (meaning three separate MediaWikis for tests at the same time)—is that sufficient? We can drop it directly in https://gitlab.wikimedia.org/repos/10nm/ultraviolet/-/settings/ci_cd#js-cicd-variables-settings (since we're admins on GitLab) or we can get it to you some other way...(?)

With the token you should be able to use catalyst-ci-client in your pipeline (with the chart ci-charts.

Check out the example in function-orchestrator.

Does that all make sense?

We need to get you a token. The token is limited to 3 environments at a time (meaning three separate MediaWikis for tests at the same time)—is that sufficient?

3 environments should be plenty - we won't need the environments to be kept up, they will (hopefully) be destroyed right after each test run.

We can drop it directly in https://gitlab.wikimedia.org/repos/10nm/ultraviolet/-/settings/ci_cd#js-cicd-variables-settings (since we're admins on GitLab)

Yes, that would work quite nicely for us! The token would end up in there one way or another anyway.

Just had a quick look at function-orchestrator, and wondering if this is correct:

  • add the include: component: ...
  • add catalyst-deploy and catalyst-cleanup to stages:
  • if we add a depends: catalyst-deploy to our test stage, we can use $MW_SERVER_URL (?)
    • how will we get the username/pass, or is this static per chart?
  • we add a depends: vitest to catalyst-cleanup so it tears down automatically

Thanks very much!

thcipriani added a project: Essential-Work.

Just had a quick look at function-orchestrator, and wondering if this is correct:

  • add the include: component: ...
  • add catalyst-deploy and catalyst-cleanup to stages:
  • if we add a depends: catalyst-deploy to our test stage, we can use $MW_SERVER_URL (?)
    • how will we get the username/pass, or is this static per chart?
  • we add a depends: vitest to catalyst-cleanup so it tears down automatically

Thanks very much!

Yes, that looks about right, although I'm not sure if you need to use depends. The usernames/passwords are defined in the ci-chart. The following are available:

  • Admin (admin account)
  • Alice
  • Bob
  • Mallory (blocked account)

The default password in the chart is dockerpass. All users will use that password. The password can be changed by setting 'mediawikiCore': { 'password': 'yourvalue' } in the json values variable of the ci job.

Do you need any other accounts?

Also, if you think your test method could be abstracted and used by other projects, we could add it as a hidden job to the ci-client just like the selenium tests are.

I've added the api token to the ultraviolet repo

Do you need any other accounts?

No, that should be enough.

Also, if you think your test method could be abstracted and used by other projects, we could add it as a hidden job to the ci-client just like the selenium tests are.

We will probably use puppeteer, so the gitlab config might be abstractable. We'll keep that in mind as we set it up!

I've added the api token to the ultraviolet repo

Thanks very much!

thcipriani assigned this task to jeena.

Looks like you've got what you need, is that right @Sportzpikachu ? Closing this out for now. Reopen if you run into issues.

Yes, that's right, thanks very much! I can see the token in the CI settings. Most likely we will start working on the integration test MVP after Easter.

Yes, that's right, thanks very much! I can see the token in the CI settings. Most likely we will start working on the integration test MVP after Easter.

Perfect. Let us know if you need anything!