Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress test. Connected file share. #3764

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ jobs:
DJANGO_SU_PASSWORD: '12qwaszx'
API_ABOUT_PAGE: "localhost:8080/api/v1/server/about"
run: |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f components/serverless/docker-compose.serverless.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f components/serverless/docker-compose.serverless.yml -f tests/docker-compose.file_share.yml up -d
/bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${API_ABOUT_PAGE})" != "401" ]]; do sleep 5; done'
docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell" docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell"
docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell"
cd ./tests
npm ci
if [[ ${{ github.ref }} == 'refs/heads/develop' ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
API_ABOUT_PAGE: "localhost:8080/api/v1/server/about"
run: |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f components/serverless/docker-compose.serverless.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f components/serverless/docker-compose.serverless.yml -f tests/docker-compose.file_share.yml up -d
/bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${API_ABOUT_PAGE})" != "401" ]]; do sleep 5; done'
docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell"
cd ./tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
DJANGO_SU_PASSWORD: "12qwaszx"
API_ABOUT_PAGE: "localhost:8080/api/v1/server/about"
run: |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f ./tests/docker-compose.email.yml -f components/serverless/docker-compose.serverless.yml up -d --build
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f ./tests/docker-compose.email.yml -f tests/docker-compose.file_share.yml -f components/serverless/docker-compose.serverless.yml up -d --build
/bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${API_ABOUT_PAGE})" != "401" ]]; do sleep 5; done'
docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell"
- name: End-to-end testing
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/reducers/notifications-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,7 @@ export default function (state = defaultState, action: AnyAction): Notifications
jobFetching: {
message: 'Could not fetch frame data from the server',
reason: action.payload.error,
className: 'cvat-notification-notice-fetch-frame-data-from-the-server-failed',
},
},
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

context('Connected file share.', () => {
const caseId = '107';
const taskName = `Case ${caseId}`;
const labelName = taskName;
let stdoutToList;
const assetLocalPath = `cypress/integration/actions_tasks3/assets/case_${caseId}`;

function createOpenTaskWithShare() {
cy.get('#cvat-create-task-button').should('be.visible').click();
cy.get('#name').type(taskName);
cy.addNewLabel(labelName);
cy.contains('[role="tab"]', 'Connected file share').click();
cy.get('.cvat-share-tree').should('be.visible').within(() => {
cy.get('[aria-label="plus-square"]').click();
cy.get('[title]').should('have.length', 4) // Also "root"
cy.exec('docker exec -i cvat /bin/bash -c "ls ~/share"').then((command) => {
stdoutToList = command.stdout.split('\n');
// [image_case_107_1.png, image_case_107_2.png, image_case_107_3.png]
expect (stdoutToList.length).to.be.eq(3);
stdoutToList.forEach((el) => {
cy.get(`[title="${el}"]`).should('exist');
// Click on the checkboxes
cy.get(`[title="${el}"]`).prev().click().should('have.attr', 'class').and('contain', 'checked');
});
});
});
cy.contains('button', 'Submit').click();
cy.get('.cvat-notification-create-task-success').should('exist').find('button').click();
cy.get('.cvat-notification-create-task-success').should('exist').find('[data-icon="close"]').click();
cy.get('.cvat-task-details').should('exist');
}

before(() => {
cy.visit('auth/login');
cy.login();
});

afterEach(() => {
cy.goToTaskList();
cy.deleteTask(taskName);
});

after(() => {
// Renaming to the original name
cy.exec(`mv ${assetLocalPath}/${stdoutToList[0]}.bk ${assetLocalPath}/${stdoutToList[0]}`);
})

describe(`Testing case "${caseId}"`, () => {
it('Create a task with "Connected file share".', () => {
createOpenTaskWithShare();
cy.openJob();
cy.get('.cvat-player-filename-wrapper').then((playerFilenameWrapper) => {
for (let el = 0; el < stdoutToList.length; el++) {
cy.get(playerFilenameWrapper).should('have.text', stdoutToList[el]);
cy.checkFrameNum(el);
cy.get('.cvat-player-next-button').click().trigger('mouseout');
}
});
});

it('Check "Fix problem with getting cloud storages in Firefox".', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

So, if this test doesn't have common with cloud storage features, maybe better to use a such message?

Suggested change
it('Check "Fix problem with getting cloud storages in Firefox".', () => {
it('Check "Fix DataCloneError: The object could not be cloned in Firefox".', () => {

or

Suggested change
it('Check "Fix problem with getting cloud storages in Firefox".', () => {
it('Check "Fix problem with getting share data for the task when data not available more in Firefox".', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose the second option. Applied locally.
Right now GitHub is having problems with actions. The jobs will start after the problems are fixed. https://www.githubstatus.com/

cy.goToTaskList();
createOpenTaskWithShare();
// Rename the image
cy.exec(`mv ${assetLocalPath}/${stdoutToList[0]} ${assetLocalPath}/${stdoutToList[0]}.bk`)
.then((fileRenameCommand) => {
expect(fileRenameCommand.code).to.be.eq(0);
});
cy.exec(`docker exec -i cvat /bin/bash -c "find ~/share -name "*.png" -type f"`)
.then((findFilesCommand) => {
// [image_case_107_2.png, image_case_107_3.png]
expect(findFilesCommand.stdout.split('\n').length).to.be.eq(2);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Why need this check if the previous command

cy.exec(`mv ${assetLocalPath}/${stdoutToList[0]} ${assetLocalPath}/${stdoutToList[0]}.bk`)
                .then((fileRenameCommand) => {
                    expect(fileRenameCommand.code).to.be.eq(0);
                });

will return code 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make sure that the file has been renamed. And there are only 2 images used in the task. Checking the exit code of the rename command has been added just in case.

cy.openJob();
cy.get('.cvat-annotation-header').should('exist');
// Error: . "\"No such file or directory /home/django/share/image_case_107_1.png\"".
cy.get('.cvat-notification-notice-fetch-frame-data-from-the-server-failed').should('exist');
cy.closeNotification('.cvat-notification-notice-fetch-frame-data-from-the-server-failed');
});
});
});
15 changes: 15 additions & 0 deletions tests/docker-compose.file_share.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.3'

services:
cvat:
environment:
CVAT_SHARE_URL: 'Mounted from asset for case 107 host directory'
volumes:
- cvat_share:/home/django/share:rw

volumes:
cvat_share:
driver_opts:
type: none
device: tests/cypress/integration/actions_tasks3/assets/case_107
o: bind