Skip to content

Commit

Permalink
Merge 662010f into 8afca46
Browse files Browse the repository at this point in the history
  • Loading branch information
Pchelolo committed Apr 14, 2019
2 parents 8afca46 + 662010f commit 9e4a973
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 230 deletions.
4 changes: 3 additions & 1 deletion config.example.wikimedia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ default_project: &default_project
storage_groups:
- name: default.group.local
domains: /./
# ignored in cassandra, but useful in SQLite testing. only used in tests.
dbname: test.db.sqlite3
parsoid:
host: https://parsoid-beta.wmflabs.org
grace_ttl: 1
grace_ttl: 1000000
action:
apiUriTemplate: "{{'https://{domain}/w/api.php'}}"
baseUriTemplate: "{{'https://{domain}/api/rest_v1'}}"
Expand Down
31 changes: 0 additions & 31 deletions sys/key_rev_value.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,36 +106,6 @@ class KRVBucket {
return hyper.get(storeReq).then(returnRevision(req));
}

listRevisions(hyper, req) {
const rp = req.params;
return hyper.get({
uri: new URI([rp.domain, 'sys', 'table', rp.bucket, '']),
body: {
table: req.params.bucket,
attributes: {
key: req.params.key
},
proj: ['rev', 'tid'],
limit: mwUtil.getLimit(hyper, req)
}
})
.then((res) => ({
status: 200,

headers: {
'content-type': 'application/json'
},

body: {
items: res.body.items.map((row) => ({
revision: row.rev,
tid: row.tid
})),
next: res.body.next
}
}));
}

putRevision(hyper, req) {
const rp = req.params;
const rev = mwUtil.parseRevision(rp.revision, 'key_rev_value');
Expand Down Expand Up @@ -185,7 +155,6 @@ module.exports = (options) => {
spec, // Re-export from spec module
operations: {
createBucket: krvBucket.createBucket.bind(krvBucket),
listRevisions: krvBucket.listRevisions.bind(krvBucket),
getRevision: krvBucket.getRevision.bind(krvBucket),
putRevision: krvBucket.putRevision.bind(krvBucket)
}
Expand Down
4 changes: 0 additions & 4 deletions sys/key_rev_value.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ paths:
put:
operationId: putRevision

/{bucket}/{key}/:
get:
operationId: listRevisions

/{bucket}/{key}/{revision}:
<<: *bucket_key

Expand Down
26 changes: 0 additions & 26 deletions sys/key_value.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,6 @@ class KVBucket {
return hyper.get(storeReq).then(returnRevision(req));
}

listRevisions(hyper, req) {
const rp = req.params;
const storeRequest = {
uri: new URI([rp.domain, 'sys', 'table', rp.bucket, '']),
body: {
table: req.params.bucket,
attributes: {
key: req.params.key
},
proj: ['tid'],
limit: 1000
}
};
return hyper.get(storeRequest)
.then((res) => ({
status: 200,
headers: {
'content-type': 'application/json'
},
body: {
items: res.body.items.map((row) => row.tid)
}
}));
}

putRevision(hyper, req) {
const rp = req.params;
let tid = rp.tid && mwUtil.coerceTid(rp.tid, 'key_value');
Expand Down Expand Up @@ -213,7 +188,6 @@ module.exports = (options) => {
spec, // Re-export from spec module
operations: {
createBucket: kvBucket.createBucket.bind(kvBucket),
listRevisions: kvBucket.listRevisions.bind(kvBucket),
getRevision: kvBucket.getRevision.bind(kvBucket),
putRevision: kvBucket.putRevision.bind(kvBucket)
}
Expand Down
4 changes: 0 additions & 4 deletions sys/key_value.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ paths:
/{bucket}:
put:
operationId: createBucket

/{bucket}/{key}:
get:
operationId: getRevision
put:
operationId: putRevision

/{bucket}/{key}/:
get:
operationId: listRevisions
3 changes: 1 addition & 2 deletions sys/multi_content_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,7 @@ module.exports = (options) => {
operations: {
createBucket: mkBucket.createBucket.bind(mkBucket),
getRevision: mkBucket.getRevision.bind(mkBucket),
putRevision: mkBucket.putRevision.bind(mkBucket),
listRevisions: mkBucket.listRevisions.bind(mkBucket)
putRevision: mkBucket.putRevision.bind(mkBucket)
}
};
};
4 changes: 0 additions & 4 deletions sys/multi_content_bucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ paths:
get:
operationId: getRevision

/{content}/{key}/:
get:
operationId: listRevisions

/{content}/{key}/{revision}:
<<: *content_key

Expand Down
30 changes: 0 additions & 30 deletions sys/parsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ class ParsoidService {
getHtml: this.getFormat.bind(this, 'html'),
getDataParsoid: this.getFormat.bind(this, 'data-parsoid'),
getLintErrors: this.getLintErrors.bind(this),
// Listings
listWikitextRevisions: this.listRevisions.bind(this, 'wikitext'),
listHtmlRevisions: this.listRevisions.bind(this, 'html'),
listDataParsoidRevisions: this.listRevisions.bind(this, 'data-parsoid'),
// Transforms
transformHtmlToHtml: this.makeTransform('html', 'html'),
transformHtmlToWikitext: this.makeTransform('html', 'wikitext'),
Expand Down Expand Up @@ -514,32 +510,6 @@ class ParsoidService {
});
}

listRevisions(format, hyper, req) {
const rp = req.params;
const revReq = {
uri: new URI([rp.domain, 'sys', 'parsoid_bucket', format, rp.title, '']),
body: {
limit: hyper.config.default_page_size
}
};

if (req.query.page) {
revReq.body.next = mwUtil.decodePagingToken(hyper, req.query.page);
}

return hyper.get(revReq)
.then((res) => {
if (res.body.next) {
res.body._links = {
next: {
href: `?page=${mwUtil.encodePagingToken(hyper, res.body.next)}`
}
};
}
return res;
});
}

_getStashedContent(hyper, req, etag) {
const rp = req.params;
const getStash = (format) => hyper.get({
Expand Down
33 changes: 0 additions & 33 deletions sys/parsoid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ paths:
summary: Retrieve the wikitext for a title and revision.
operationId: getWikitext

/wikitext/{title}/:
get:
summary: List Wikitext revisions.
operationId: listWikitextRevisions
parameters:
- name: page
in: query
description: The next page token
type: string
required: false

/wikitext/{title}/{revision}:
<<: *wikitext_title

Expand All @@ -48,17 +37,6 @@ paths:
summary: Retrieve the HTML for title and revision.
operationId: getHtml

/html/{title}/:
get:
summary: List HTML revisions.
operationId: listHtmlRevisions
parameters:
- name: page
in: query
description: The next page token
type: string
required: false

/html/{title}/{revision}:
<<: *html_title

Expand All @@ -70,17 +48,6 @@ paths:
summary: Retrieve the data-parsoid JSON for title & revision.
operationId: getDataParsoid

/data-parsoid/{title}/:
get:
summary: List data-parsoid revisions.
operationId: listDataParsoidRevisions
parameters:
- name: page
in: query
description: The next page token
type: string
required: false

/data-parsoid/{title}/{revision}:
<<: *data-parsoid_title

Expand Down
21 changes: 10 additions & 11 deletions test/features/buckets/key_value_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,29 @@ describe('Key value buckets', () => {

it('key_value should not overwrite same content with ignore_duplicates', () => {
const testData = randomString(100);
const tids = [ uuid.now().toString(),
const originalEtag = uuid.now().toString();
const etags = [ originalEtag,
uuid.now().toString(),
uuid.now().toString() ];
return P.each(tids, (tid) => {
return preq.put({
return P.each(etags, (etag) => preq.put({
uri: `${bucketBaseURI}/List_Test_1`,
body: new Buffer(testData),
headers: {
'if-none-hash-match': '*'
'if-none-hash-match': '*',
etag
}
})
.catch(() => {});
})
.catch(() => {
})
)
.then(() => {
return preq.get({
uri: `${bucketBaseURI}/List_Test_1/`,
query: {
limit: 10
}
uri: `${bucketBaseURI}/List_Test_1`
});
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.body.items.length, 1);
assert.deepEqual(res.headers.etag, originalEtag);
});
});
}
Expand Down
23 changes: 0 additions & 23 deletions test/features/buckets/revisioned_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,6 @@ describe('Revisioned buckets', () => {
});
});

it('lists revisions', () => {
const testData = randomString(100);
return P.each([1, 2, 3], (revNumber) => {
return preq.put({
uri: `${bucketBaseURI}/Test5/${revNumber}`,
body: new Buffer(testData)
});
})
.then(() => {
return preq.get({
uri: `${bucketBaseURI}/Test5/`,
query: {
limit: 10
}
});
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.body.items.length, 3);
assert.deepEqual(res.body.items.map((r) => { return r.revision; }), [3, 2, 1]);
});
});

it('throws error on invalid revision', () => {
const testData = randomString(100);
return preq.put({
Expand Down
7 changes: 3 additions & 4 deletions test/features/pagecontent/pagecontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ describe('item requests', function() {
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept'], disallow: [''] });
return preq.get({
uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Main_Page/`
uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Main_Page`
});
})
.then((res) => {
if (res.body.items.length !== 1) {
throw new Error('Expected a single revision for Main_Page');
}
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept'], disallow: [''] });
});
});
it('should transparently create a new HTML revision with id 252937', () => {
Expand Down
12 changes: 0 additions & 12 deletions test/features/pagecontent/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ describe('redirects', () => {
});
});

it('should preserve parameters while redirecting to a normalized version of a title, #2', () => {
return preq.get({
uri: `${server.config.bucketURL()}/html/Main%20Page/`,
followRedirect: false
})
.then((res) => {
assert.deepEqual(res.status, 301);
assert.deepEqual(res.headers.location, '../Main_Page/');
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
});
});

it('should not redirect to a normalized version of a title, no-cache', () => {
return preq.get({
uri: `${server.config.bucketURL()}/html/Main%20Page?test=mwAQ`,
Expand Down
Loading

0 comments on commit 9e4a973

Please sign in to comment.