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
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
Cypress.Commands.add('createZipArchive', function (directoryToArchive, arhivePath) {
|
Cypress.Commands.add('createZipArchive', (directoryToArchive, arhivePath, level = 9) => cy.task('createZipArchive', {
|
||||||
return cy.task('createZipArchive', {
|
directoryToArchive,
|
||||||
directoryToArchive: directoryToArchive,
|
arhivePath,
|
||||||
arhivePath: arhivePath,
|
level,
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|||||||
@ -1,33 +1,45 @@
|
|||||||
// Copyright (C) 2020 Intel Corporation
|
// Copyright (C) 2020-2021 Intel Corporation
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-use-before-define
|
||||||
exports.imageGenerator = imageGenerator;
|
exports.imageGenerator = imageGenerator;
|
||||||
|
|
||||||
const jimp = require('jimp');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const jimp = require('jimp');
|
||||||
|
|
||||||
function imageGenerator(args) {
|
function createImage(width, height, color) {
|
||||||
const directory = args.directory;
|
return new Promise((resolve, reject) => {
|
||||||
const fileName = args.fileName;
|
// eslint-disable-next-line new-cap, no-new
|
||||||
const width = args.width;
|
new jimp(width, height, color, ((err, img) => {
|
||||||
const height = args.height;
|
if (err) reject(err);
|
||||||
const color = args.color;
|
resolve(img);
|
||||||
const posX = args.posX;
|
}));
|
||||||
const posY = args.posY;
|
});
|
||||||
const message = args.message;
|
}
|
||||||
const file = path.join(directory, fileName);
|
|
||||||
const count = args.count;
|
function appendText(image, posX, posY, message, index) {
|
||||||
return new Promise((resolve, reject) => {
|
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++) {
|
for (let i = 1; i <= count; i++) {
|
||||||
new jimp(width, height, color, function (err, image) {
|
let image = await createImage(width, height, color);
|
||||||
if (err) reject(err);
|
image = await appendText(image, posX, posY, message, i);
|
||||||
jimp.loadFont(jimp.FONT_SANS_64_BLACK, function (err, font) {
|
image.write(`${file}_${i}.${extension}`);
|
||||||
if (err) reject(err);
|
|
||||||
image.print(font, Number(posX), Number(posY), `${message}. Num ${i}`).write(`${file}_${i}.png`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
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
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
Cypress.Commands.add('imageGenerator', (directory, fileName, width, height, color, posX, posY, message, count) => {
|
Cypress.Commands.add('imageGenerator', (directory, fileName, width, height, color, posX, posY, message, count, extension = 'png') => cy.task('imageGenerator', {
|
||||||
return cy.task('imageGenerator', {
|
directory,
|
||||||
directory: directory,
|
fileName,
|
||||||
fileName: fileName,
|
width,
|
||||||
width: width,
|
height,
|
||||||
height: height,
|
color,
|
||||||
color: color,
|
posX,
|
||||||
posX: posX,
|
posY,
|
||||||
posY: posY,
|
message,
|
||||||
message: message,
|
count,
|
||||||
count: count,
|
extension,
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|||||||
Loading…
Reference in New Issue