-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use brotli compression for some KP assets (#64367)
- Loading branch information
Showing
15 changed files
with
274 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,6 +398,8 @@ | |
'@types/good-squeeze', | ||
'inert', | ||
'@types/inert', | ||
'accept', | ||
'@types/accept', | ||
], | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/** | ||
* These supertest-based tests live in the functional test suite because they depend on the optimizer bundles being built | ||
* and served | ||
*/ | ||
export default function({ getService }) { | ||
const supertest = getService('supertest'); | ||
|
||
describe('bundle compression', function() { | ||
this.tags('ciGroup12'); | ||
|
||
let buildNum; | ||
before(async () => { | ||
const resp = await supertest.get('/api/status').expect(200); | ||
buildNum = resp.body.version.build_number; | ||
}); | ||
|
||
it('returns gzip files when client only supports gzip', () => | ||
supertest | ||
// We use the kbn-ui-shared-deps for these tests since they are always built with br compressed outputs, | ||
// even in dev. Bundles built by @kbn/optimizer are only built with br compression in dist mode. | ||
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) | ||
.set('Accept-Encoding', 'gzip') | ||
.expect(200) | ||
.expect('Content-Encoding', 'gzip')); | ||
|
||
it('returns br files when client only supports br', () => | ||
supertest | ||
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) | ||
.set('Accept-Encoding', 'br') | ||
.expect(200) | ||
.expect('Content-Encoding', 'br')); | ||
|
||
it('returns br files when client only supports gzip and br', () => | ||
supertest | ||
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) | ||
.set('Accept-Encoding', 'gzip, br') | ||
.expect(200) | ||
.expect('Content-Encoding', 'br')); | ||
|
||
it('returns gzip files when client prefers gzip', () => | ||
supertest | ||
.get(`/${buildNum}/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js`) | ||
.set('Accept-Encoding', 'gzip;q=1.0, br;q=0.5') | ||
.expect(200) | ||
.expect('Content-Encoding', 'gzip')); | ||
|
||
it('returns gzip files when no brotli version exists', () => | ||
supertest | ||
.get(`/${buildNum}/bundles/commons.style.css`) // legacy optimizer does not create brotli outputs | ||
.set('Accept-Encoding', 'gzip, br') | ||
.expect(200) | ||
.expect('Content-Encoding', 'gzip')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { FtrProviderContext } from 'test/functional/ftr_provider_context'; | ||
import { format as formatUrl } from 'url'; | ||
|
||
import supertestAsPromised from 'supertest-as-promised'; | ||
|
||
export function KibanaSupertestProvider({ getService }: FtrProviderContext) { | ||
const config = getService('config'); | ||
const kibanaServerUrl = formatUrl(config.get('servers.kibana')); | ||
return supertestAsPromised(kibanaServerUrl); | ||
} |
Oops, something went wrong.