mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
grep works with command
updated build scripts acceptence tests break, files are written as root when user is node
This commit is contained in:
parent
551e8d36b4
commit
4c96abd6c5
10 changed files with 47 additions and 32 deletions
|
@ -10,6 +10,7 @@ DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
||||||
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||||
BRANCH_NAME=$(BRANCH_NAME) \
|
BRANCH_NAME=$(BRANCH_NAME) \
|
||||||
PROJECT_NAME=$(PROJECT_NAME) \
|
PROJECT_NAME=$(PROJECT_NAME) \
|
||||||
|
MOCHA_GREP=${MOCHA_GREP} \
|
||||||
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -21,13 +22,13 @@ clean:
|
||||||
test: test_unit test_acceptance
|
test: test_unit test_acceptance
|
||||||
|
|
||||||
test_unit:
|
test_unit:
|
||||||
@[ ! -d test/unit ] && echo "clsi has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit -- ${MOCHA_ARGS}
|
@[ ! -d test/unit ] && echo "clsi has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit
|
||||||
|
|
||||||
test_acceptance: test_clean # clear the database before each acceptance test run
|
test_acceptance: test_clean # clear the database before each acceptance test run
|
||||||
@[ ! -d test/acceptance ] && echo "clsi has no acceptance tests" || $(DOCKER_COMPOSE) run --rm test_acceptance -- ${MOCHA_ARGS}
|
@[ ! -d test/acceptance ] && echo "clsi has no acceptance tests" || $(DOCKER_COMPOSE) run --rm test_acceptance
|
||||||
|
|
||||||
test_clean:
|
test_clean:
|
||||||
$(DOCKER_COMPOSE) down -t -v 0
|
$(DOCKER_COMPOSE) down -v -t 0
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker build --pull --tag quay.io/sharelatex/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) .
|
docker build --pull --tag quay.io/sharelatex/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) .
|
||||||
|
|
|
@ -182,7 +182,7 @@ server = net.createServer (socket) ->
|
||||||
logger.err err:err, "error with socket on load check"
|
logger.err err:err, "error with socket on load check"
|
||||||
socket.destroy()
|
socket.destroy()
|
||||||
|
|
||||||
if STATE == "up" and settings.load_balancer_agent.report_load
|
if STATE == "up" and Settings.load_balancer_agent.report_load
|
||||||
currentLoad = os.loadavg()[0]
|
currentLoad = os.loadavg()[0]
|
||||||
|
|
||||||
# staging clis's have 1 cpu core only
|
# staging clis's have 1 cpu core only
|
||||||
|
@ -206,7 +206,7 @@ server = net.createServer (socket) ->
|
||||||
|
|
||||||
port = (Settings.internal?.clsi?.port or 3013)
|
port = (Settings.internal?.clsi?.port or 3013)
|
||||||
host = (Settings.internal?.clsi?.host or "localhost")
|
host = (Settings.internal?.clsi?.host or "localhost")
|
||||||
load_port = settings.internal.clsi.load_port or 3048
|
load_port = Settings.internal.clsi.load_port or 3048
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,13 @@ module.exports = ResourceWriter =
|
||||||
logger.err err:err, project_id:project_id, path:path, resource_url:resource.url, modified:resource.modified, "error downloading file for resources"
|
logger.err err:err, project_id:project_id, path:path, resource_url:resource.url, modified:resource.modified, "error downloading file for resources"
|
||||||
callback() #try and continue compiling even if http resource can not be downloaded at this time
|
callback() #try and continue compiling even if http resource can not be downloaded at this time
|
||||||
else
|
else
|
||||||
|
process = require("process")
|
||||||
|
console.log "writing file out", path, process.getuid()
|
||||||
fs.writeFile path, resource.content, callback
|
fs.writeFile path, resource.content, callback
|
||||||
|
try
|
||||||
|
result = fs.lstatSync(path)
|
||||||
|
console.log "path stats", result
|
||||||
|
catch e
|
||||||
|
|
||||||
checkPath: (basePath, resourcePath, callback) ->
|
checkPath: (basePath, resourcePath, callback) ->
|
||||||
path = Path.normalize(Path.join(basePath, resourcePath))
|
path = Path.normalize(Path.join(basePath, resourcePath))
|
||||||
|
|
|
@ -12,6 +12,8 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- ./compiles:/app/compiles
|
- ./compiles:/app/compiles
|
||||||
|
- ./cache:/app/cache
|
||||||
|
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
environment:
|
environment:
|
||||||
|
@ -24,4 +26,4 @@ services:
|
||||||
SQLITE_PATH: /app/compiles/db.sqlite
|
SQLITE_PATH: /app/compiles/db.sqlite
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:rw
|
- /var/run/docker.sock:/var/run/docker.sock:rw
|
||||||
- ./compiles:/app/compiles
|
- ./cache:/app/cache
|
||||||
|
|
|
@ -8,8 +8,7 @@ version: "2"
|
||||||
services:
|
services:
|
||||||
test_unit:
|
test_unit:
|
||||||
image: quay.io/sharelatex/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
image: quay.io/sharelatex/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||||
user: node
|
command: npm run test:unit:_run
|
||||||
entrypoint: npm run test:unit:_run
|
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
build: .
|
build: .
|
||||||
|
@ -23,8 +22,7 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- mongo
|
- mongo
|
||||||
user: node
|
command: npm run test:acceptance:_run
|
||||||
entrypoint: npm run test:acceptance:_run
|
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
|
|
|
@ -11,8 +11,9 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
user: node
|
environment:
|
||||||
entrypoint: npm run test:unit
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
|
command: npm run test:unit
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
build: .
|
build: .
|
||||||
|
@ -25,11 +26,12 @@ services:
|
||||||
environment:
|
environment:
|
||||||
REDIS_HOST: redis
|
REDIS_HOST: redis
|
||||||
MONGO_HOST: mongo
|
MONGO_HOST: mongo
|
||||||
user: node
|
environment:
|
||||||
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- mongo
|
- mongo
|
||||||
entrypoint: npm run test:acceptance
|
command: npm run test:acceptance
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Changing permissions of /var/run/docker.sock for sibling containers"
|
echo "Changing permissions of /var/run/docker.sock for sibling containers"
|
||||||
|
ls -al /var/run/docker.sock
|
||||||
|
docker --version
|
||||||
|
cat /etc/passwd
|
||||||
|
usermod -aG docker node
|
||||||
chown root:docker /var/run/docker.sock
|
chown root:docker /var/run/docker.sock
|
||||||
|
|
||||||
mkdir -p /app/cache
|
mkdir -p /app/cache
|
||||||
|
@ -10,7 +13,10 @@ chown -R node:node /app/cache
|
||||||
mkdir -p /app/compiles
|
mkdir -p /app/compiles
|
||||||
chown -R node:node /app/compiles
|
chown -R node:node /app/compiles
|
||||||
|
|
||||||
|
chown -R node:node /app/bin/synctex
|
||||||
|
mkdir -p /app/test/acceptance/fixtures/tmp/
|
||||||
|
chown -R node:node /app
|
||||||
|
|
||||||
|
|
||||||
./bin/install_texlive_gce.sh
|
./bin/install_texlive_gce.sh
|
||||||
echo "HELOOOo"
|
|
||||||
echo "$@"
|
|
||||||
exec runuser -u node "$@"
|
exec runuser -u node "$@"
|
|
@ -2,12 +2,3 @@
|
||||||
wget -qO- https://get.docker.com/ | sh
|
wget -qO- https://get.docker.com/ | sh
|
||||||
apt-get install poppler-utils vim ghostscript --yes
|
apt-get install poppler-utils vim ghostscript --yes
|
||||||
npm rebuild
|
npm rebuild
|
||||||
usermod -aG docker node
|
|
||||||
|
|
||||||
mkdir -p /app/cache
|
|
||||||
chown -R node:node /app/cache
|
|
||||||
|
|
||||||
mkdir -p /app/compiles
|
|
||||||
chown -R node:node /app/compiles
|
|
||||||
|
|
||||||
chown -R node:node /app/bin/synctex
|
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
"compile": "npm run compile:app && npm run compile:test:acceptance && npm run compile:test:smoke",
|
"compile": "npm run compile:app && npm run compile:test:acceptance && npm run compile:test:smoke",
|
||||||
"start": "npm run compile:app && node $NODE_APP_OPTIONS app.js",
|
"start": "npm run compile:app && node $NODE_APP_OPTIONS app.js",
|
||||||
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
||||||
"test:acceptance": "npm run compile:app && npm run compile:acceptance_tests && npm run test:acceptance:_run -- $@",
|
"test:acceptance": "npm run compile:app && npm run compile:acceptance_tests && npm run test:acceptance:_run -- --grep=$MOCHA_GREP",
|
||||||
"test:unit:_run": "mocha --recursive --exit --reporter spec $@ test/unit/js",
|
"test:unit:_run": "mocha --recursive --exit --reporter spec $@ test/unit/js",
|
||||||
"test:unit": "npm run compile:app && npm run compile:unit_tests && npm run test:unit:_run -- $@",
|
"test:unit": "npm run compile:app && npm run compile:unit_tests && npm run test:unit:_run -- --grep=$MOCHA_GREP",
|
||||||
"compile:unit_tests": "[ -e test/unit ] && coffee -o test/unit/js -c test/unit/coffee || echo 'No unit tests to compile'",
|
"compile:unit_tests": "[ -e test/unit ] && coffee -o test/unit/js -c test/unit/coffee || echo 'No unit tests to compile'",
|
||||||
"compile:acceptance_tests": "[ -e test/acceptance ] && coffee -o test/acceptance/js -c test/acceptance/coffee || echo 'No acceptance tests to compile'",
|
"compile:acceptance_tests": "[ -e test/acceptance ] && coffee -o test/acceptance/js -c test/acceptance/coffee || echo 'No acceptance tests to compile'",
|
||||||
"compile:all": "npm run compile:app && npm run compile:unit_tests && npm run compile:acceptance_tests",
|
"compile:all": "npm run compile:app && npm run compile:unit_tests && npm run compile:acceptance_tests",
|
||||||
|
|
|
@ -4,15 +4,21 @@ require("chai").should()
|
||||||
fs = require "fs"
|
fs = require "fs"
|
||||||
ChildProcess = require "child_process"
|
ChildProcess = require "child_process"
|
||||||
ClsiApp = require "./helpers/ClsiApp"
|
ClsiApp = require "./helpers/ClsiApp"
|
||||||
|
logger = require("logger-sharelatex")
|
||||||
fixturePath = (path) -> __dirname + "/../fixtures/" + path
|
Path = require("path")
|
||||||
|
fixturePath = (path) -> Path.normalize(__dirname + "/../fixtures/" + path)
|
||||||
|
process = require "process"
|
||||||
|
console.log process.pid, process.ppid, process.getuid(),process.getgroups(), "PID"
|
||||||
try
|
try
|
||||||
|
console.log "creating tmp directory", fixturePath("tmp")
|
||||||
fs.mkdirSync(fixturePath("tmp"))
|
fs.mkdirSync(fixturePath("tmp"))
|
||||||
catch e
|
catch err
|
||||||
|
console.log err, fixturePath("tmp"), "unable to create fixture tmp path"
|
||||||
|
|
||||||
convertToPng = (pdfPath, pngPath, callback = (error) ->) ->
|
convertToPng = (pdfPath, pngPath, callback = (error) ->) ->
|
||||||
command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}"
|
command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}"
|
||||||
|
console.log "COMMAND"
|
||||||
|
console.log command
|
||||||
convert = ChildProcess.exec command
|
convert = ChildProcess.exec command
|
||||||
stdout = ""
|
stdout = ""
|
||||||
convert.stdout.on "data", (chunk) -> console.log "STDOUT", chunk.toString()
|
convert.stdout.on "data", (chunk) -> console.log "STDOUT", chunk.toString()
|
||||||
|
@ -58,6 +64,8 @@ compareMultiplePages = (project_id, callback = (error) ->) ->
|
||||||
compareNext 0, callback
|
compareNext 0, callback
|
||||||
|
|
||||||
comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
||||||
|
console.log "CONVERT"
|
||||||
|
console.log "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png"
|
||||||
convertToPng "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png", (error) =>
|
convertToPng "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png", (error) =>
|
||||||
throw error if error?
|
throw error if error?
|
||||||
convertToPng "examples/#{example_dir}/output.pdf", "tmp/#{project_id}-source.png", (error) =>
|
convertToPng "examples/#{example_dir}/output.pdf", "tmp/#{project_id}-source.png", (error) =>
|
||||||
|
@ -76,6 +84,7 @@ comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
||||||
downloadAndComparePdf = (project_id, example_dir, url, callback = (error) ->) ->
|
downloadAndComparePdf = (project_id, example_dir, url, callback = (error) ->) ->
|
||||||
writeStream = fs.createWriteStream(fixturePath("tmp/#{project_id}.pdf"))
|
writeStream = fs.createWriteStream(fixturePath("tmp/#{project_id}.pdf"))
|
||||||
request.get(url).pipe(writeStream)
|
request.get(url).pipe(writeStream)
|
||||||
|
console.log("writing file out", fixturePath("tmp/#{project_id}.pdf"))
|
||||||
writeStream.on "close", () =>
|
writeStream.on "close", () =>
|
||||||
checkPdfInfo "tmp/#{project_id}.pdf", (error, optimised) =>
|
checkPdfInfo "tmp/#{project_id}.pdf", (error, optimised) =>
|
||||||
throw error if error?
|
throw error if error?
|
||||||
|
|
Loading…
Reference in a new issue