Skip to content

Commit 526f0fc

Browse files
authored
Merge pull request #4391 from nextcloud/ci/flaky-stable27
[stable27] Flaky CI fixes
2 parents c66a7ef + 11b3428 commit 526f0fc

File tree

10 files changed

+96
-92
lines changed

10 files changed

+96
-92
lines changed

.github/workflows/cypress.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,21 @@ jobs:
7575
node-version: [16]
7676
containers: [1, 2, 3, 4, 5, 6, 7, 8]
7777
php-versions: [ '8.1' ]
78-
databases: [ 'sqlite' ]
7978
server-versions: ['stable27']
8079

8180
name: runner ${{ matrix.containers }}
8281

82+
services:
83+
postgres:
84+
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest
85+
ports:
86+
- 4444:5432/tcp
87+
env:
88+
POSTGRES_USER: root
89+
POSTGRES_PASSWORD: rootpassword
90+
POSTGRES_DB: nextcloud
91+
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
92+
8393
steps:
8494
- name: Restore context
8595
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
@@ -101,7 +111,7 @@ jobs:
101111
uses: shivammathur/setup-php@v2
102112
with:
103113
php-version: ${{ matrix.php-versions }}
104-
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, zip, gd, apcu
114+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql
105115
ini-values:
106116
apc.enable_cli=on
107117
coverage: none
@@ -113,7 +123,7 @@ jobs:
113123
run: |
114124
mkdir data
115125
echo '<?php $CONFIG=["memcache.local"=>"\OC\Memcache\APCu","hashing_default_password"=>true];' > config/config.php
116-
php occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
126+
php occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
117127
php -f index.php
118128
php -S 0.0.0.0:8081 &
119129
export OC_PASS=1234561

.github/workflows/phpunit-mysql.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ jobs:
5656
# Split and keep last
5757
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
5858
59-
- name: Enable ONLY_FULL_GROUP_BY MySQL option
60-
run: |
61-
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
62-
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
63-
6459
- name: Checkout server
6560
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
6661
with:
@@ -73,6 +68,11 @@ jobs:
7368
with:
7469
path: apps/${{ env.APP_NAME }}
7570

71+
- name: Enable ONLY_FULL_GROUP_BY MySQL option
72+
run: |
73+
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
74+
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
75+
7676
- name: Set up php ${{ matrix.php-versions }}
7777
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
7878
with:

.github/workflows/phpunit-oci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ concurrency:
3434

3535
jobs:
3636
phpunit-oci:
37-
runs-on: ubuntu-latest
37+
runs-on: ubuntu-22.04
3838

3939
strategy:
4040
matrix:

cypress/e2e/attachments.spec.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222

2323
import { initUserAndFiles, randHash, randUser } from '../utils/index.js'
24-
import 'cypress-file-upload'
2524

2625
const user = randUser()
2726
const recipient = randUser()
@@ -41,7 +40,12 @@ function attachFile(name, requestAlias = null) {
4140
}
4241
return cy.getEditor()
4342
.find('input[type="file"][data-text-el="attachment-file-input"]')
44-
.attachFile(name)
43+
.selectFile([
44+
{
45+
contents: 'cypress/fixtures/' + name,
46+
fileName: name,
47+
},
48+
], { force: true })
4549
}
4650

4751
/**
@@ -406,10 +410,4 @@ describe('Test all attachment insertion methods', () => {
406410
}
407411
})
408412
})
409-
410-
it('Delete the user', () => {
411-
cy.deleteUser(user)
412-
cy.deleteUser(recipient)
413-
})
414-
415413
})

cypress/e2e/nodes/ImageView.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ describe('Image View', () => {
1515
before(() => {
1616
cy.createUser(user)
1717
cy.login(user)
18-
cy.visit('/apps/files')
1918

2019
// Upload test files to user's storage
2120
cy.createFolder('child-folder')

cypress/e2e/nodes/Mentions.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { initUserAndFiles, randUser } from '../../utils/index.js'
2-
import 'cypress-file-upload'
32

43
const user = randUser()
54
const mentionMe = randUser()

cypress/e2e/sync.spec.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,31 @@ describe('Sync', () => {
6666

6767
it('recovers from a lost connection', () => {
6868
let count = 0
69-
cy.intercept({ method: 'POST', url: '**/apps/text/session/push' }, (req) => {
70-
if (count < 5) {
71-
count++
69+
cy.intercept({ method: 'PUT', url: '**/apps/text/session/create' })
70+
.as('createSession')
71+
cy.intercept({ method: 'POST', url: '**/apps/text/session/*' }, (req) => {
72+
if (count < 4) {
7273
req.destroy()
7374
req.alias = 'dead'
75+
} else {
76+
req.alias = 'alive'
7477
}
75-
}).as('push')
76-
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }, (req) => {
77-
if (count < 5) {
78-
count++
79-
req.destroy()
80-
req.alias = 'deadSync'
81-
}
82-
})
83-
cy.get('#editor-container .document-status')
84-
.should('contain', 'File could not be loaded', { timeout: 10000 })
85-
cy.get('#editor-container .document-status', { timeout: 30000 })
86-
.should('not.contain', 'File could not be loaded')
78+
}).as('sessionRequests')
79+
cy.wait('@dead', { timeout: 30000 })
80+
cy.get('#editor-container .document-status', { timeout: 10000 })
81+
.should('contain', 'File could not be loaded')
82+
.then(() => {
83+
count = 4
84+
})
85+
cy.wait('@alive', { timeout: 30000 })
8786
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' })
8887
.as('syncAfterRecovery')
88+
cy.wait('@syncAfterRecovery', { timeout: 30000 })
89+
cy.get('#editor-container .document-status', { timeout: 30000 })
90+
.should('not.contain', 'File could not be loaded')
91+
// FIXME: There seems to be a bug where typed words maybe lost if not waiting for the new session
92+
cy.wait('@createSession')
93+
cy.wait('@syncAfterRecovery')
8994
cy.getContent().type('* more content added after the lost connection{enter}')
9095
cy.wait('@syncAfterRecovery')
9196
cy.closeFile()

cypress/support/commands.js

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,61 @@ addCommands()
3636
// and also to determine paths, urls and the like.
3737
let auth
3838
Cypress.Commands.overwrite('login', (login, user) => {
39+
cy.window().then((win) => {
40+
win.location.href = 'about:blank'
41+
})
3942
auth = { user: user.userId, password: user.password }
4043
login(user)
4144
})
4245

4346
Cypress.Commands.add('ocsRequest', (options) => {
44-
return cy.request({
45-
form: true,
46-
auth,
47-
headers: {
48-
'OCS-ApiRequest': 'true',
49-
'Content-Type': 'application/x-www-form-urlencoded',
50-
},
51-
...options,
52-
})
47+
return cy.request('/csrftoken')
48+
.then(({ body }) => body.token)
49+
.then(requesttoken => {
50+
return cy.request({
51+
form: true,
52+
auth,
53+
headers: {
54+
'OCS-ApiRequest': 'true',
55+
'Content-Type': 'application/x-www-form-urlencoded',
56+
requesttoken,
57+
},
58+
...options,
59+
})
60+
})
5361
})
5462

5563
Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
56-
return cy.fixture(fileName, 'base64')
57-
.then(Cypress.Blob.base64StringToBlob)
64+
return cy.fixture(fileName, 'binary')
65+
.then(Cypress.Blob.binaryStringToBlob)
5866
.then(blob => {
59-
const file = new File([blob], fileName, { type: mimeType })
6067
if (typeof target !== 'undefined') {
6168
fileName = target
6269
}
63-
return cy.request('/csrftoken')
64-
.then(({ body }) => body.token)
65-
.then(requesttoken => {
66-
return axios.put(`${url}/remote.php/webdav/${fileName}`, file, {
70+
cy.request('/csrftoken')
71+
.then(({ body }) => {
72+
return cy.wrap(body.token)
73+
})
74+
.then(async (requesttoken) => {
75+
return cy.request({
76+
url: `${url}/remote.php/webdav/${fileName}`,
77+
method: 'put',
78+
body: blob.size > 0 ? blob : '',
79+
auth,
6780
headers: {
6881
requesttoken,
6982
'Content-Type': mimeType,
7083
},
71-
}).then(response => {
72-
const fileId = Number(
73-
response.headers['oc-fileid']?.split('oc')?.[0]
74-
)
75-
cy.log(`Uploaded ${fileName}`,
76-
response.status,
77-
{ fileId }
78-
)
79-
return fileId
8084
})
85+
}).then(response => {
86+
const fileId = Number(
87+
response.headers['oc-fileid']?.split('oc')?.[0]
88+
)
89+
cy.log(`Uploaded ${fileName}`,
90+
response.status,
91+
{ fileId }
92+
)
93+
return cy.wrap(fileId)
8194
})
8295
})
8396
})
@@ -95,27 +108,27 @@ Cypress.Commands.add('downloadFile', (fileName) => {
95108
})
96109

97110
Cypress.Commands.add('createFile', (target, content, mimeType = 'text/markdown') => {
98-
const fileName = target.split('/').pop()
99-
100111
const blob = new Blob([content], { type: mimeType })
101-
const file = new File([blob], fileName, { type: mimeType })
102112

103-
return cy.window()
104-
.then(async win => {
105-
const response = await axios.put(`${url}/remote.php/webdav/${target}`, file, {
113+
return cy.request('/csrftoken')
114+
.then(({ body }) => body.token)
115+
.then(requesttoken => {
116+
return cy.request({
117+
url: `${url}/remote.php/webdav/${target}`,
118+
method: 'put',
119+
body: blob.size > 0 ? blob : '',
120+
auth,
106121
headers: {
107-
requesttoken: win.OC.requestToken,
108122
'Content-Type': mimeType,
123+
requesttoken,
109124
},
125+
}).then((response) => {
126+
return cy.log(`Uploaded ${target}`, response.status)
110127
})
111-
112-
return cy.log(`Uploaded ${fileName}`, response.status)
113128
})
114-
115129
})
116130

117131
Cypress.Commands.add('shareFileToUser', (path, targetUser, shareData = {}) => {
118-
cy.clearCookies()
119132
cy.ocsRequest({
120133
method: 'POST',
121134
url: `${url}/ocs/v2.php/apps/files_sharing/api/v1/shares`,
@@ -212,7 +225,8 @@ Cypress.Commands.add('createFolder', (target) => {
212225
return cy.request('/csrftoken')
213226
.then(({ body }) => body.token)
214227
.then(requesttoken => {
215-
return axios.request(`${rootPath}/${dirPath}`, {
228+
return cy.request({
229+
url: `${rootPath}/${dirPath}`,
216230
method: 'MKCOL',
217231
auth,
218232
headers: {

package-lock.json

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
"@vue/test-utils": "^1.3.0 <2",
125125
"@vue/vue2-jest": "^29.2.4",
126126
"cypress": "^12.16.0",
127-
"cypress-file-upload": "^5.0.8",
128127
"eslint-plugin-cypress": "^2.13.3",
129128
"identity-obj-proxy": "^3.0.0",
130129
"jest": "^29.5.0",

0 commit comments

Comments
 (0)