Skip to content

Commit

Permalink
Issue 1281 warning on no write (#7126)
Browse files Browse the repository at this point in the history
* replace fs write error with warning

This change replaces the error with a warning
when cypress is executing tests in a readonly fs.

* some cleanup

- don't need to run test in a specific browser
- can combine SS + video test into one
- don't seem to need readonly_fs_spec.js

* if videos folder cannot be created, just warn

* try a non-root e2e test stage

* fix comment

* FOLDER_NOT_ACCESSIBLE

Co-authored-by: Fabian Wiles <fabianwiles@live.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
  • Loading branch information
3 people authored May 12, 2020
1 parent 3558479 commit f5284c6
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 34 deletions.
62 changes: 36 additions & 26 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ executors:
# Docker image with non-root "node" user
non-root-docker-user:
docker:
- image: cypress/base:12.0.0
- image: cypress/browsers:node12.13.0-chrome80-ff74
user: node
environment:
PLATFORM: linux
Expand Down Expand Up @@ -122,7 +122,7 @@ commands:
type: string
chunk:
description: e2e test chunk number
type: integer
type: string
steps:
- attach_workspace:
at: ~/
Expand Down Expand Up @@ -410,168 +410,174 @@ jobs:
steps:
- run-e2e-tests:
browser: chrome
chunk: 1
chunk: "1"

"server-e2e-tests-chrome-2":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 2
chunk: "2"

"server-e2e-tests-chrome-3":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 3
chunk: "3"

"server-e2e-tests-chrome-4":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 4
chunk: "4"

"server-e2e-tests-chrome-5":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 5
chunk: "5"

"server-e2e-tests-chrome-6":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 6
chunk: "6"

"server-e2e-tests-chrome-7":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 7
chunk: "7"

"server-e2e-tests-chrome-8":
<<: *defaults
steps:
- run-e2e-tests:
browser: chrome
chunk: 8
chunk: "8"

"server-e2e-tests-electron-1":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 1
chunk: "1"

"server-e2e-tests-electron-2":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 2
chunk: "2"

"server-e2e-tests-electron-3":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 3
chunk: "3"

"server-e2e-tests-electron-4":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 4
chunk: "4"

"server-e2e-tests-electron-5":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 5
chunk: "5"

"server-e2e-tests-electron-6":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 6
chunk: "6"

"server-e2e-tests-electron-7":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 7
chunk: "7"

"server-e2e-tests-electron-8":
<<: *defaults
steps:
- run-e2e-tests:
browser: electron
chunk: 8
chunk: "8"

"server-e2e-tests-non-root":
<<: *defaults
steps:
- run-e2e-tests:
chunk: non_root

"server-e2e-tests-firefox-1":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 1
chunk: "1"

"server-e2e-tests-firefox-2":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 2
chunk: "2"

"server-e2e-tests-firefox-3":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 3
chunk: "3"

"server-e2e-tests-firefox-4":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 4
chunk: "4"

"server-e2e-tests-firefox-5":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 5
chunk: "5"

"server-e2e-tests-firefox-6":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 6
chunk: "6"

"server-e2e-tests-firefox-7":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 7
chunk: "7"

"server-e2e-tests-firefox-8":
<<: *defaults
steps:
- run-e2e-tests:
browser: firefox
chunk: 8
chunk: "8"

"driver-integration-tests-chrome":
<<: *defaults
Expand Down Expand Up @@ -1232,6 +1238,10 @@ linux-workflow: &linux-workflow
- server-e2e-tests-electron-8:
requires:
- build
- server-e2e-tests-non-root:
executor: non-root-docker-user
requires:
- build
- server-e2e-tests-firefox-1:
requires:
- build
Expand Down
82 changes: 82 additions & 0 deletions packages/server/__snapshots__/non_root_read_only_fs_spec.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
exports['e2e readonly fs / warns when unable to write to disk'] = `
Folder /foo/bar/.projects/read-only-project-root is not writable.
Writing to this directory is required by Cypress in order to store screenshots and videos.
Enable write permissions to this directory to ensure screenshots and videos are stored.
If you don't require screenshots or videos to be stored you can safely ignore this warning.
✅ not running as root
✅ /foo/bar/.projects/read-only-project-root is not writable
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (spec.js) │
│ Searched: cypress/integration/spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: spec.js (1 of 1)
Warning: We failed to record the video.
This error will not alter the exit code.
Error: EACCES: permission denied, mkdir '/foo/bar/.projects/read-only-project-root/cypress/videos'
1) fails
0 passing
1 failing
1) fails:
Error: EACCES: permission denied, mkdir '/foo/bar/.projects/read-only-project-root/cypress/screenshots'
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
Warning: We failed processing this video.
This error will not alter the exit code.
Error: ffmpeg exited with code 1: /foo/bar/.projects/read-only-project-root/cypress/videos/spec.js.mp4: No such file or directory
[stack trace lines]
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ spec.js XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) XX:XX 1 - 1 - -
`
10 changes: 10 additions & 0 deletions packages/server/lib/errors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,16 @@ getMsgByType = (type, arg1 = {}, arg2, arg3) ->
To avoid this error, ensure that there are no other instances of Firefox launched by Cypress running.
"""
when "FOLDER_NOT_WRITABLE"
"""
Folder #{arg1} is not writable.
Writing to this directory is required by Cypress in order to store screenshots and videos.
Enable write permissions to this directory to ensure screenshots and videos are stored.
If you don't require screenshots or videos to be stored you can safely ignore this warning.
"""

get = (type, arg1, arg2, arg3) ->
msg = getMsgByType(type, arg1, arg2, arg3)
Expand Down
15 changes: 8 additions & 7 deletions packages/server/lib/modes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,17 +645,18 @@ const trashAssets = Promise.method((config = {}) => {
const createVideoRecording = function (videoName, options = {}) {
const outputDir = path.dirname(videoName)

const onError = _.once((err) => {
// catch video recording failures and log them out
// but don't let this affect the run at all
return errors.warning('VIDEO_RECORDING_FAILED', err.stack)
})

return fs
.ensureDirAsync(outputDir)
.catch(onError)
.then(() => {
return videoCapture
.start(videoName, _.extend({}, options, {
onError (err) {
// catch video recording failures and log them out
// but don't let this affect the run at all
return errors.warning('VIDEO_RECORDING_FAILED', err.stack)
},
}))
.start(videoName, _.extend({}, options, { onError }))
})
}

Expand Down
4 changes: 3 additions & 1 deletion packages/server/lib/util/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ module.exports = {
log('cannot find file %s', file)

return this._err('CONFIG_FILE_NOT_FOUND', this.configFile(options), projectRoot)
}).catch({ code: 'EACCES' }, () => {
// we cannot write due to folder permissions
return errors.warning('FOLDER_NOT_WRITABLE', projectRoot)
}).catch((err) => {
if (errors.isCypressErr(err)) {
throw err
}

// else we cannot read due to folder permissions
return this._logReadErr(file, err)
})
},
Expand Down
Loading

4 comments on commit f5284c6

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f5284c6 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/linux-x64/circle-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-322708/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/circle-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-322694/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f5284c6 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/win32-ia32/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.6.0/win32-ia32/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/win32-ia32/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/win32-ia32/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f5284c6 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/win32-x64/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.6.0/win32-x64/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/win32-x64/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/win32-x64/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.6.0/appveyor-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-32820147/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f5284c6 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.6.0/darwin-x64/circle-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-322774/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.6.0/circle-develop-f5284c66050690b7d768e241dd5177cf5553c5b7-322717/cypress.tgz

Please sign in to comment.