Bugfix / tests: Travis use LibreOffice PPA and fix import /export tests for good. (#4166)

Just final bits of test coverage for import/export of LibreOffice.  It turns out Travis by default installs an old LO that doesn't support PDF import.  To remedy that I use the LO PPA and also strict install the PDF import support.

Still to do in a future date is check LO exported contents includes expected strings, for now it just checks output length looks sane.
pull/4172/head
John McLear 2020-07-16 10:46:45 +01:00 committed by GitHub
parent 9bf1b9f2a2
commit 7b0fd4fb29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 33 deletions

View File

@ -9,7 +9,10 @@ services:
cache: false cache: false
before_install: before_install:
- sudo add-apt-repository -y ppa:libreoffice/ppa
- sudo apt-get update
- sudo apt-get -y install libreoffice - sudo apt-get -y install libreoffice
- sudo apt-get -y install libreoffice-pdfimport
install: install:
- "bin/installDeps.sh" - "bin/installDeps.sh"
@ -38,20 +41,17 @@ jobs:
- name: "Run the Backend tests" - name: "Run the Backend tests"
install: install:
- "bin/installDeps.sh" - "bin/installDeps.sh"
# Set soffice to /usr/bin/soffice
- "sed 's/\"soffice\": null,/\"soffice\": \"/usr/bin/soffice\",/g' settings.json.template > settings.json"
# Set allowAnyoneToImport to true
- "sed 's/\"allowAnyoneToImport\": false,/\"allowAnyoneToInput\": true,/g' settings.json > settings.json"
- "cd src && npm install && cd -" - "cd src && npm install && cd -"
script: script:
- "tests/frontend/travis/runnerBackend.sh" - "tests/frontend/travis/runnerBackend.sh"
- name: "Test the Dockerfile" ## Temporarily commented out the Dockerfile tests
install: # - name: "Test the Dockerfile"
- "cd src && npm install && cd -" # install:
script: # - "cd src && npm install && cd -"
- "docker build -t etherpad:test ." # script:
- "docker run -d -p 9001:9001 etherpad:test && sleep 3" # - "docker build -t etherpad:test ."
- "cd src && npm run test-container" # - "docker run -d -p 9001:9001 etherpad:test && sleep 3"
# - "cd src && npm run test-container"
- name: "Load test Etherpad" - name: "Load test Etherpad"
install: install:
- "bin/installDeps.sh" - "bin/installDeps.sh"

View File

@ -1,12 +1,7 @@
/* /*
* Import and Export tests for the /p/whateverPadId/import and /p/whateverPadId/export endpoints. * Import and Export tests for the /p/whateverPadId/import and /p/whateverPadId/export endpoints.
* Executed using request. Designed to find flaws and bugs
*/ */
// import wont work due to sessions missing
// Waiting on https://github.com/ether/etherpad-lite/pull/4012/files to be merged to be fully functional
// Logic for creating sessions is the sessionandGroups.js test spec
const assert = require('assert'); const assert = require('assert');
const supertest = require(__dirname+'/../../../../src/node_modules/supertest'); const supertest = require(__dirname+'/../../../../src/node_modules/supertest');
const fs = require('fs'); const fs = require('fs');
@ -77,10 +72,9 @@ Example Curl command for testing import URI:
*/ */
describe('Imports and Exports', function(){ describe('Imports and Exports', function(){
it('creates a new Pad, imports content to it, checks that content', function(done) { it('creates a new Pad, imports content to it, checks that content', function(done) {
if(!settings.allowAnyoneToImport){ if(!settings.allowAnyoneToImport){
console.log("not anyone can import so not testing -- to include this test set allowAnyoneToImport to true in settings.json"); console.warn("not anyone can import so not testing -- to include this test set allowAnyoneToImport to true in settings.json");
done(); done();
}else{ }else{
api.get(endPoint('createPad')+"&padID="+testPadId) api.get(endPoint('createPad')+"&padID="+testPadId)
@ -138,18 +132,21 @@ describe('Imports and Exports', function(){
}); });
}); });
xit('exports DOC', function(done) { it('exports DOC', function(done) {
if(!settings.allowAnyoneToImport) return done(); if(!settings.allowAnyoneToImport) return done();
if((settings.abiword && settings.abiword.indexOf("/" === -1)) && (settings.office && settings.soffice.indexOf("/" === -1))) return done(); if((settings.abiword && settings.abiword.indexOf("/" === -1)) && (settings.office && settings.soffice.indexOf("/" === -1))) return done();
request(host + '/p/'+testPadId+'/export/doc', function (err, res, body) { try{
// expect length to be > 9000 request(host + '/p/'+testPadId+'/export/doc', function (err, res, body) {
// TODO: At some point checking that the contents is correct would be suitable // TODO: At some point checking that the contents is correct would be suitable
if(body.length >= 9000){ if(body.length >= 9000){
done(); done();
}else{ }else{
throw new Error("Word Document export length is not right"); throw new Error("Word Document export length is not right");
} }
}) })
}catch(e){
throw new Error(e);
}
}) })
it('Tries to import .docx that uses soffice or abiword', function(done) { it('Tries to import .docx that uses soffice or abiword', function(done) {
@ -161,7 +158,7 @@ describe('Imports and Exports', function(){
throw new Error("Failed to import", err); throw new Error("Failed to import", err);
} else { } else {
if(res.body.indexOf("FrameCall('undefined', 'ok');") === -1){ if(res.body.indexOf("FrameCall('undefined', 'ok');") === -1){
throw new Error("Failed DOCX import", testPadId); throw new Error("Failed DOCX import");
}else{ }else{
done(); done();
}; };
@ -197,7 +194,7 @@ describe('Imports and Exports', function(){
throw new Error("Failed to import", err); throw new Error("Failed to import", err);
} else { } else {
if(res.body.indexOf("FrameCall('undefined', 'ok');") === -1){ if(res.body.indexOf("FrameCall('undefined', 'ok');") === -1){
throw new Error("Failed PDF import", testPadId); throw new Error("Failed PDF import");
}else{ }else{
done(); done();
}; };

Binary file not shown.

View File

@ -9,6 +9,15 @@ MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# reliably move to the etherpad base folder before running it # reliably move to the etherpad base folder before running it
cd "${MY_DIR}/../../../" cd "${MY_DIR}/../../../"
# Set soffice to /usr/bin/soffice
sed 's#\"soffice\": null,#\"soffice\":\"/usr/bin/soffice\",#g' settings.json.template > settings.json.soffice
# Set allowAnyoneToImport to true
sed 's/\"allowAnyoneToImport\": false,/\"allowAnyoneToImport\": true,/g' settings.json.soffice > settings.json.allowImport
# Set "max": 10 to 100 to not agressively rate limit
sed 's/\"max\": 10/\"max\": 10/g' settings.json.allowImport > settings.json
# start Etherpad, assuming all dependencies are already installed. # start Etherpad, assuming all dependencies are already installed.
# #
# This is possible because the "install" section of .travis.yml already contains # This is possible because the "install" section of .travis.yml already contains
@ -28,9 +37,6 @@ echo "Now I will try for 15 seconds to connect to Etherpad on http://localhost:9
echo "Successfully connected to Etherpad on http://localhost:9001" echo "Successfully connected to Etherpad on http://localhost:9001"
# a copy of settings.json is necessary for the backend tests to work
cp settings.json.template settings.json
# run the backend tests # run the backend tests
echo "Now run the backend tests" echo "Now run the backend tests"
cd src cd src