Skip to content

Conversation

@hknustwmf
Copy link
Contributor

It may look like a lot of changes, but there are actually only a few. The key pieces are parsoid.js and the new test variant_config.js. The transform.js test battery is now executed twice -- once for each variant. The tests themselves did not change except for the headers.

@hknustwmf hknustwmf requested a review from d00rman August 23, 2019 21:26
@Pchelolo
Copy link
Contributor

I haven't looked in any of the details, but I strongly disagree with the implementation approach taken here.

Touching parsoid.js in this manner was never intended and doing so creates so much more complexity... Here's what needs to be done in my opinion:

  1. We need to mount sys/parsoid.js in project twice under 2 separate paths with 2 separate options - one for JS and one for PHP
  2. Instead of mounting /v1/parsoid.yaml we need to write a little JS proxy module that would look at the cookie and decide which parsoid version (PHP vs JS) to use, call it, and add a Vary header in the end - that way all the code related to this transition will be confined to a single place and not spread around the codebase. This change will be removed after full transition anyway, so we want it to be as self-confined as possible
  3. I don't understand the purpose of one more copy of the config. What we need to do is to have tests running for JS parsoid-only, for PHP parsoid-only and maybe one or two tests verifying that actual switching works. For the purpose of the first two, we can add support in preq to set additional headers based on an environment variable and add one more dimention in the travis testing matrix. For the second - we just write a couple of new tests in a separate suite.

@d00rman
Copy link
Contributor

d00rman commented Aug 26, 2019

Touching parsoid.js in this manner was never intended and doing so creates so much more complexity... Here's what needs to be done in my opinion:

I agree. Too many places in parsoid.js have been touched just for the transition period. I agree with @Pchelolo on the course of action outlined below. Some comments follow.

  1. We need to mount sys/parsoid.js in project twice under 2 separate paths with 2 separate options - one for JS and one for PHP
  2. Instead of mounting /v1/parsoid.yaml we need to write a little JS proxy module that would look at the cookie and decide which parsoid version (PHP vs JS) to use, call it, and add a Vary header in the end - that way all the code related to this transition will be confined to a single place and not spread around the codebase. This change will be removed after full transition anyway, so we want it to be as self-confined as possible

I agree this is the way to go, but there are some caveats. These could be mounted onto /sys/parsoid/ and /sys/parsoidphp/. In the mount options, then, one would get the Parsoid/JS host supplied for parsoidHost, while the other would get the Parsoid/PHP host. Additionally, each would need an extra option passed to it, bucket_name (or similar) that instructs it which buckets to use (the values are parsoid and parsoidphp respectively).

  1. I don't understand the purpose of one more copy of the config. What we need to do is to have tests running for JS parsoid-only, for PHP parsoid-only and maybe one or two tests verifying that actual switching works. For the purpose of the first two, we can add support in preq to set additional headers based on an environment variable and add one more dimention in the travis testing matrix. For the second - we just write a couple of new tests in a separate suite.

I think we can tackle the tests after the first two points have been completed (but still in this PR).

Copy link
Contributor

@d00rman d00rman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be reworked as per above discussion.

@d00rman d00rman changed the title T230791 - Have a Mechanism for Storing and Retrieving Parsoid HTML from JS and PHP Mechanism for storing and retrieving Parsoid HTML from JS and PHP Aug 26, 2019
@hknustwmf
Copy link
Contributor Author

Needs to be reworked as per above discussion.

I added the proxy and a couple basic tests.

Copy link
Contributor

@d00rman d00rman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave it a first pass, but looking much better now.

@hknustwmf hknustwmf force-pushed the T230791 branch 2 times, most recently from 5d61671 to 9f86111 Compare September 4, 2019 14:42
.then((res) => {
if (res) {
res.headers = res.headers || {};
res.headers[VARIANT_HDR_NAME] = rootReqHeaders[VARIANT_HDR_NAME];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure this is a right behavior that wouldn't accidentally mask issues. We assume we've routed the request to correct Parsoid, but who knows? Why would we set the response header for parsed variant here??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the ticket: "Furthermore, RESTBase must include this header in the response, ..." https://phabricator.wikimedia.org/T230791

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the variant header would be added by the Parsoid instances instead of Restbase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what I meant. Or, the content-type would be different. Would you mind filing a ticket, something like 'Parsoid JS/PHP should indicate which Parsoid implementation the page was rendered with'?

@Pchelolo
Copy link
Contributor

Pchelolo commented Sep 5, 2019

A couple of issues left, but you're close.

One thing I'm wondering about is testing. With the current patch we will be testing PHP parsoid compatibility with exactly 1 test. We need more. We need to have an env variable that would set a parsoid variant header in preq for all requests, (I believe we'd need to support this in preq, but maybe request already supports something like that. Needs to be checked). Then we need to add 2 versions of this variable to the test matrix in travis.yaml - that would allow us to run all the tests with both parsoid versions and be sure we're compatible with both.

Copy link
Contributor Author

@hknustwmf hknustwmf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like request has support for what you want to do. Do you intend to modify the tests with the additional header field? The value would be whatever the env var says or JS as the default?

Copy link
Contributor

@Pchelolo Pchelolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like request has support for what you want to do. Do you intend to modify the tests with the additional header field? The value would be whatever the env var says or JS as the default?

There's https://github.com/request/request#requestdefaultsoptions. We can add this to 'preq' as well - preq.defaults will return a wrapper that will modify the request options. Should be fairly easy to achieve. Then we can modify the tests to require some instance of preq from utils and that one would be a wrapper based on an env var.

I've realized we can't really add the header based on the env var in preq itself cause we use preq not only in test code but in the application code as well.

@Pchelolo
Copy link
Contributor

Pchelolo commented Oct 3, 2019

  1. This needs to be manually rebased.
  2. Now that we have parsoid in beta accessible, we can pick up the work here again. See T231569 for reference regarding parsoid in beta cluster.

There's a bunch of things to be done to be able to run CI and local testing agains Parsoid-PHP. We can't access production wikis on beta PHP Parsoid, see T231933 so we need to convert all the tests to only talk to beta wikis. I think we can work on that in separate PRs.

@hknustwmf
Copy link
Contributor Author

hknustwmf commented Oct 4, 2019

Based on the discussion with Giuseppe yesterday, let's also think about/create tasks to remove external dependencies from integration tests.

@Pchelolo
Copy link
Contributor

Pchelolo commented Oct 4, 2019

Based on the discussion with Giuseppe yesterday, let's also think about/create tasks to remove external dependencies from integration tests.

Creating tasks makes sense, but actually blocking this on them is a bit too ambitious in my opinion.

@hknustwmf
Copy link
Contributor Author

hknustwmf commented Oct 4, 2019

It was meant as a suggestion not a blocker

@d00rman
Copy link
Contributor

d00rman commented Oct 13, 2019

Superseded by #1207

@d00rman d00rman closed this Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants