Skip to content

Commit 4142764

Browse files
committed
Changes for T230791 Have a Mechanism for Storing and Retrieving Parsoid HTML from JS and PHP
1 parent d08ad0e commit 4142764

File tree

11 files changed

+652
-245
lines changed

11 files changed

+652
-245
lines changed

config.example.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ services:
5252
# XXX Check the base RESTBase URI
5353
baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
5454
parsoid:
55-
# XXX Check Parsoid URL!
55+
# XXX Check Parsoid/JS URL!
5656
host: http://localhost:8142
57+
# XXX Check Parsoid/PHP URL!
58+
php_host: http://localhost:8142
5759
table:
5860
backend: sqlite
5961
dbname: db.sqlite3

config.frontend.test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ default_project: &default_project
99
options: &default_options
1010
parsoid:
1111
host: https://parsoid-beta.wmflabs.org
12+
# TODO: replace with actual Parsoid/PHP host when available
13+
php_host: https://parsoid-beta.wmflabs.org
1214
grace_ttl: 1000000
1315
action:
1416
apiUriTemplate: "{{'https://{domain}/w/api.php'}}"

config.fullstack.test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ default_project: &default_project
88
options: &default_options
99
parsoid:
1010
host: https://parsoid-beta.wmflabs.org
11+
# TODO: replace with actual Parsoid/PHP host when available
12+
php_host: https://parsoid-beta.wmflabs.org
1113
grace_ttl: 1000000
1214
action:
1315
apiUriTemplate: "{{'https://{domain}/w/api.php'}}"
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
default_project: &default_project
2+
x-modules:
3+
- spec:
4+
paths:
5+
/{api:v1}:
6+
x-modules:
7+
- path: projects/v1/default.wmf.yaml
8+
options: &default_options
9+
parsoid:
10+
host: https://parsoid-beta.wmflabs.org
11+
grace_ttl: 1000000
12+
action:
13+
apiUriTemplate: "{{'https://{domain}/w/api.php'}}"
14+
baseUriTemplate: "{{'https://{domain}/api/rest_v1'}}"
15+
graphoid:
16+
host: https://graphoid-beta.wmflabs.org
17+
mathoid: &mathoid_options
18+
host: https://mathoid-beta.wmflabs.org
19+
# 10 days Varnish caching, one day client-side
20+
cache-control: s-maxage=864000, max-age=86400
21+
mobileapps:
22+
host: https://appservice.wmflabs.org
23+
summary:
24+
protocol: https
25+
implementation: mcs
26+
host: https://appservice.wmflabs.org
27+
citoid:
28+
host: https://citoid-beta.wmflabs.org
29+
recommendation:
30+
host: https://recommendation-api-beta.wmflabs.org
31+
purged_cache_control: test_purged_cache_control
32+
# Cache control for purged endpoints allowing short-term client caching
33+
purged_cache_control_client_cache: test_purged_cache_control_with_client_caching
34+
pdf:
35+
# Cache PDF for 5 minutes since it's not purged
36+
cache_control: s-maxage=600, max-age=600
37+
uri: https://proton-beta.wmflabs.org
38+
transform:
39+
cx_host: https://cxserver-beta.wmflabs.org
40+
skip_updates: false
41+
- path: projects/proxy.yaml
42+
options: &proxy_options
43+
backend_host_template: '{{"/{domain}/sys/legacy"}}'
44+
block_external_reqs: true
45+
/{api:sys}: &default_sys
46+
x-modules:
47+
- path: projects/sys/default.wmf.yaml
48+
options: *default_options
49+
- path: projects/proxy.yaml
50+
options:
51+
<<: *proxy_options
52+
block_external_reqs: false
53+
- spec:
54+
paths:
55+
/legacy/key_value:
56+
x-modules:
57+
- path: sys/key_value.js
58+
/legacy/page_revisions:
59+
x-modules:
60+
- path: sys/page_revisions.js
61+
/table: &table_spec
62+
x-modules:
63+
- path: sys/table.js
64+
options:
65+
conf:
66+
backend: '{env(RB_TEST_BACKEND, sqlite)}'
67+
hosts: [localhost]
68+
keyspace: system
69+
username: cassandra
70+
password: cassandra
71+
defaultConsistency: one # or 'localQuorum' for production
72+
storage_groups:
73+
- name: test.group.local
74+
domains: /./
75+
# ignored in cassandra, but useful in SQLite testing
76+
dbname: '{env(RB_SQLITE_FILE, test.db.sqlite3)}'
77+
78+
wikimedia_project: &wikimedia_project
79+
x-modules:
80+
- spec:
81+
paths:
82+
/{api:v1}:
83+
x-modules:
84+
- path: projects/v1/wikimedia.wmf.yaml
85+
options:
86+
<<: *default_options
87+
pageviews:
88+
host: https://wikimedia.org/api/rest_v1/metrics
89+
- path: projects/proxy.yaml
90+
options: *proxy_options
91+
/{api:sys}:
92+
x-modules:
93+
- path: projects/proxy.yaml
94+
options:
95+
<<: *proxy_options
96+
block_external_reqs: false
97+
- spec:
98+
paths:
99+
/legacy/key_value:
100+
x-modules:
101+
- path: sys/key_value.js
102+
/table: *table_spec
103+
/mathoid:
104+
x-modules:
105+
- path: sys/mathoid.js
106+
options: *mathoid_options
107+
/post_data:
108+
x-modules:
109+
- path: sys/post_data.js
110+
/events:
111+
x-modules:
112+
- path: sys/events.js
113+
# No options provided deliberately to avoid log noise upon testing
114+
115+
wikipedia_project: &wikipedia_project
116+
x-modules:
117+
- spec:
118+
paths:
119+
/{api:v1}:
120+
x-modules:
121+
- path: projects/v1/wikipedia.wmf.yaml
122+
options: *default_options
123+
- path: projects/proxy.yaml
124+
options: *proxy_options
125+
/{api:sys}: *default_sys
126+
127+
wiktionary_project: &wiktionary_project
128+
x-modules:
129+
- spec:
130+
paths:
131+
/{api:v1}:
132+
x-modules:
133+
- path: projects/v1/wiktionary.wmf.yaml
134+
options: *default_options
135+
- path: projects/proxy.yaml
136+
options: *proxy_options
137+
/{api:sys}: *default_sys
138+
139+
commons_project: &commons_project
140+
x-modules:
141+
- spec:
142+
paths:
143+
/{api:v1}:
144+
x-modules:
145+
- path: projects/v1/default.wmf.yaml
146+
options: *default_options
147+
- spec:
148+
paths:
149+
/data:
150+
x-modules:
151+
- path: v1/recommend-caption.yaml
152+
options: '{{options.recommendation}}'
153+
options: *default_options
154+
- path: projects/proxy.yaml
155+
options: *proxy_options
156+
/{api:sys}: *default_sys
157+
158+
wikidata_project: &wikidata_project
159+
x-modules:
160+
- spec:
161+
paths:
162+
/{api:v1}:
163+
x-modules:
164+
- path: projects/v1/wikidata.wmf.yaml
165+
options: *default_options
166+
- path: projects/proxy.yaml
167+
options: *proxy_options
168+
/{api:sys}: *default_sys
169+
170+
testing_project: &testing_project
171+
x-modules:
172+
- spec:
173+
paths:
174+
/{api:v1}:
175+
x-modules:
176+
- path: test/test_module.yaml
177+
options:
178+
events:
179+
uri: http://127.0.0.1:8085/v1/events
180+
stream: resource_change
181+
transcludes_stream: change-prop.transcludes.resource-change
182+
- path: projects/proxy.yaml
183+
options: *proxy_options
184+
/{api:sys}: *default_sys
185+
186+
# Hacky way to parametrize RESTBase tests. TODO: Move to config?
187+
test:
188+
content_types:
189+
html: '/^text\/html; charset=utf-8; profile="https:\/\/www\.mediawiki\.org\/wiki\/Specs\/HTML\/[\d.]+"$/'
190+
data-parsoid: '/^application\/json; charset=utf-8; profile="https:\/\/www\.mediawiki\.org\/wiki\/Specs\/data-parsoid/[\d.]+"$/'
191+
wikitext: '/^text\/plain; charset=utf-8; profile="https:\/\/www.mediawiki.org\/wiki\/Specs\/wikitext\/[\d.]+"$/'
192+
193+
194+
# The root of the spec tree. Domains tend to share specs by referencing them
195+
# using YAML references.
196+
spec_root: &spec_root
197+
title: "The RESTBase root"
198+
# Some more general RESTBase info
199+
x-request-filters:
200+
- path: lib/security_response_header_filter.js
201+
202+
x-sub-request-filters:
203+
- type: default
204+
name: http
205+
options:
206+
allow:
207+
- pattern: /^https?:\/\/[a-zA-Z0-9\.]+\/w\/api\.php/
208+
forward_headers: true
209+
- pattern: /^https?:\/\/parsoid-beta.wmflabs.org.+/
210+
forward_headers: true
211+
- pattern: /^https?:\/\//
212+
paths:
213+
/{domain:test.wikipedia.org}: *wikipedia_project
214+
# The order is important for tests.
215+
# Redirect tests require en.wiki being not the first wiki in the list.
216+
/{domain:en.wikipedia.org}: *wikipedia_project
217+
/{domain:ru.wikipedia.org}: *wikipedia_project
218+
/{domain:de.wikipedia.org}: *wikipedia_project
219+
/{domain:test2.wikipedia.org}: *wikipedia_project
220+
/{domain:commons.wikimedia.org}: *commons_project
221+
/{domain:www.wikidata.org}: *wikidata_project
222+
223+
# labs, used for most tests
224+
/{domain:en.wikipedia.beta.wmflabs.org}: *wikipedia_project
225+
/{domain:commons.wikimedia.beta.wmflabs.org}: *commons_project
226+
/{domain:wikidata.beta.wmflabs.org}: *wikidata_project
227+
228+
# Serbian wiki in beta for language variants tests
229+
/{domain:sr.wikipedia.beta.wmflabs.org}: *wikipedia_project
230+
231+
# For security testing we rely on mocks, so it's OK to use French wiki.
232+
/{domain:fr.wikipedia.org}:
233+
<<: *wikipedia_project
234+
x-route-filters:
235+
- path: ./lib/mediawiki_auth_filter.js
236+
options:
237+
permissions:
238+
- read
239+
240+
# global domain
241+
/{domain:wikimedia.org}: *wikimedia_project
242+
243+
# Wiktionary has some specific endpoints
244+
/{domain:en.wiktionary.org}: *wiktionary_project
245+
246+
# Fake domain to run tests relying on test_module
247+
/{domain:fake.wikipedia.org}: *testing_project
248+
249+
# Finally, a standard service-runner config.
250+
info:
251+
name: restbase
252+
253+
services:
254+
- name: restbase
255+
module: hyperswitch
256+
conf: &rb_conf
257+
# In production we expose both 7231 and 7233 ports from fullstack RB.
258+
port: 7233
259+
spec: *spec_root
260+
salt: secret
261+
default_page_size: 1
262+
user_agent: RESTBase-testsuite
263+
ui_name: RESTBase
264+
ui_url: https://www.mediawiki.org/wiki/RESTBase
265+
ui_title: RESTBase docs
266+
267+
logging:
268+
name: restbase-test
269+
level: warn
270+
streams:
271+
- type: stdout
272+
273+
num_workers: 0

projects/example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ paths:
5656
- path: sys/parsoid.js
5757
options:
5858
parsoidHost: '{{options.parsoid.host}}'
59+
parsoidPhpHost: '{{options.parsoid.php_host}}'
5960
response_cache_control: '{{options.purged_cache_control}}'
6061
grace_ttl: '{{default(options.parsoid.grace_ttl, 86400)}}'
6162
options: '{{options}}'

projects/sys/default.wmf.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ paths:
1414
- path: sys/parsoid.js
1515
options:
1616
parsoidHost: '{{options.parsoid.host}}'
17+
parsoidPhpHost: '{{options.parsoid.php_host}}'
1718
response_cache_control: '{{options.purged_cache_control}}'
1819
grace_ttl: '{{default(options.parsoid.grace_ttl, 86400)}}'
1920
# A list of pages that we don't currently want to re-render on

0 commit comments

Comments
 (0)