Add documentation/tests for tasks large files uploads (#4036)
* added api documentation * added test with 108mb file * fixed linter issues * added upload chunk size param * fixed initialization * udpated doc for uploadChunkSize * reworked setting as global * small fix * moved uploadChunkSize setting setup to hooks * fix comments * change this to globalThismain
parent
2ebe7176cf
commit
69d3ad79f6
@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2020-2021 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
context('Create task with tus file', () => {
|
||||
const caseId = '112';
|
||||
const labelName = `Case ${caseId}`;
|
||||
const taskName = `New annotation task for ${labelName}`;
|
||||
const attrName = `Attr for ${labelName}`;
|
||||
const textDefaultValue = 'Some default value for type Text';
|
||||
const imagesCount = 1;
|
||||
const imageFileName = `image_${labelName.replace(' ', '_').toLowerCase()}`;
|
||||
const width = 1920;
|
||||
const height = 1080;
|
||||
const posX = 10;
|
||||
const posY = 10;
|
||||
const color = 'gray';
|
||||
const archiveName = `${imageFileName}.zip`;
|
||||
const archivePath = `cypress/fixtures/${archiveName}`;
|
||||
const imagesFolder = `cypress/fixtures/${imageFileName}`;
|
||||
const directoryToArchive = imagesFolder;
|
||||
const zipLevel = 0;
|
||||
const extension = 'bmp';
|
||||
|
||||
before(() => {
|
||||
cy.visit('auth/login');
|
||||
cy.login();
|
||||
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX,
|
||||
posY, labelName, imagesCount, extension);
|
||||
cy.createZipArchive(directoryToArchive, archivePath, zipLevel);
|
||||
cy.window().then((win) => { win.cvat.config.uploadChunkSize = 5; });
|
||||
});
|
||||
|
||||
describe(`Testing "${labelName}"`, () => {
|
||||
it('Create a task with 5mb upload chunk size', () => {
|
||||
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName);
|
||||
});
|
||||
|
||||
it('Check if task exist', () => {
|
||||
cy.goToTaskList();
|
||||
cy.contains('.cvat-item-task-name', taskName).should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.window().then((win) => { win.cvat.config.uploadChunkSize = 100; });
|
||||
});
|
||||
});
|
||||
@ -1,10 +1,9 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// Copyright (C) 2020-2021 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
Cypress.Commands.add('createZipArchive', function (directoryToArchive, arhivePath) {
|
||||
return cy.task('createZipArchive', {
|
||||
directoryToArchive: directoryToArchive,
|
||||
arhivePath: arhivePath,
|
||||
});
|
||||
});
|
||||
Cypress.Commands.add('createZipArchive', (directoryToArchive, arhivePath, level = 9) => cy.task('createZipArchive', {
|
||||
directoryToArchive,
|
||||
arhivePath,
|
||||
level,
|
||||
}));
|
||||
|
||||
@ -1,33 +1,45 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// Copyright (C) 2020-2021 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
exports.imageGenerator = imageGenerator;
|
||||
|
||||
const jimp = require('jimp');
|
||||
const path = require('path');
|
||||
const jimp = require('jimp');
|
||||
|
||||
function imageGenerator(args) {
|
||||
const directory = args.directory;
|
||||
const fileName = args.fileName;
|
||||
const width = args.width;
|
||||
const height = args.height;
|
||||
const color = args.color;
|
||||
const posX = args.posX;
|
||||
const posY = args.posY;
|
||||
const message = args.message;
|
||||
const file = path.join(directory, fileName);
|
||||
const count = args.count;
|
||||
function createImage(width, height, color) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// eslint-disable-next-line new-cap, no-new
|
||||
new jimp(width, height, color, ((err, img) => {
|
||||
if (err) reject(err);
|
||||
resolve(img);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
function appendText(image, posX, posY, message, index) {
|
||||
return new Promise((resolve, reject) => {
|
||||
jimp.loadFont(jimp.FONT_SANS_64_BLACK, (err, font) => {
|
||||
if (err) reject(err);
|
||||
image.print(font, Number(posX), Number(posY), `${message}. Num ${index}`);
|
||||
resolve(image);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function imageGenerator(args) {
|
||||
const {
|
||||
directory, fileName, width, height, color, posX, posY, message, count, extension,
|
||||
} = args;
|
||||
const file = path.join(directory, fileName);
|
||||
try {
|
||||
for (let i = 1; i <= count; i++) {
|
||||
new jimp(width, height, color, function (err, image) {
|
||||
if (err) reject(err);
|
||||
jimp.loadFont(jimp.FONT_SANS_64_BLACK, function (err, font) {
|
||||
if (err) reject(err);
|
||||
image.print(font, Number(posX), Number(posY), `${message}. Num ${i}`).write(`${file}_${i}.png`);
|
||||
});
|
||||
});
|
||||
let image = await createImage(width, height, color);
|
||||
image = await appendText(image, posX, posY, message, i);
|
||||
image.write(`${file}_${i}.${extension}`);
|
||||
}
|
||||
setTimeout(() => resolve(null), '1000');
|
||||
});
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,17 +1,16 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// Copyright (C) 2020-2021 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
Cypress.Commands.add('imageGenerator', (directory, fileName, width, height, color, posX, posY, message, count) => {
|
||||
return cy.task('imageGenerator', {
|
||||
directory: directory,
|
||||
fileName: fileName,
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
posX: posX,
|
||||
posY: posY,
|
||||
message: message,
|
||||
count: count,
|
||||
});
|
||||
});
|
||||
Cypress.Commands.add('imageGenerator', (directory, fileName, width, height, color, posX, posY, message, count, extension = 'png') => cy.task('imageGenerator', {
|
||||
directory,
|
||||
fileName,
|
||||
width,
|
||||
height,
|
||||
color,
|
||||
posX,
|
||||
posY,
|
||||
message,
|
||||
count,
|
||||
extension,
|
||||
}));
|
||||
|
||||
Loading…
Reference in New Issue