usersUtils.createUser(server.url, server.accessToken, username, password, next)
},
function (next) {
- const name = 'my super name for pod'
- const category = 5
- const description = 'my super description for pod'
- const tags = [ 'tag' ]
- const file = 'video_short2.webm'
- videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {}
+ videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, next)
},
function (next) {
videosUtils.getVideosList(server.url, function (err, res) {
},
// Upload some videos on each pods
function (next) {
- const name = 'my super name for pod'
- const category = 2
- const description = 'my super description for pod'
- const tags = [ 'tag' ]
- const file = 'video_short2.webm'
- videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {}
+ videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, next)
},
function (next) {
videosUtils.getVideosList(server.url, function (err, res) {
}
function uploadVideo (podNumber, callback) {
- const name = 'my super video'
- const category = 5
- const description = 'my super description'
- const tags = [ 'tag1', 'tag2' ]
- const fixture = 'video_short.webm'
+ const videoAttributes = {
+ tags: [ 'tag1', 'tag2' ]
+ }
const server = servers[podNumber - 1]
- return videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, fixture, callback)
+ return videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, callback)
}
function getVideos (podNumber, callback) {
require('./users')
require('./single-pod')
require('./multiple-pods')
+require('./requests')
require('./friends-advanced')
series([
function (next) {
- const name = 'my super name for pod 1'
- const category = 5
- const description = 'my super description for pod 1'
- const tags = [ 'tag1p1', 'tag2p1' ]
- const file = 'video_short1.webm'
- videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {
+ name: 'my super name for pod 1',
+ description: 'my super description for pod 1',
+ tags: [ 'tag1p1', 'tag2p1' ],
+ fixture: 'video_short1.webm'
+ }
+ videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, next)
},
function (next) {
setTimeout(next, 11000)
series([
function (next) {
- const name = 'my super name for pod 2'
- const category = 4
- const description = 'my super description for pod 2'
- const tags = [ 'tag1p2', 'tag2p2', 'tag3p2' ]
- const file = 'video_short2.webm'
- videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {
+ name: 'my super name for pod 2',
+ category: 4,
+ description: 'my super description for pod 2',
+ tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
+ fixture: 'video_short2.webm'
+ }
+ videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, next)
},
function (next) {
setTimeout(next, 11000)
series([
function (next) {
- const name = 'my super name for pod 3'
- const category = 6
- const description = 'my super description for pod 3'
- const tags = [ 'tag1p3' ]
- const file = 'video_short3.webm'
- videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {
+ name: 'my super name for pod 3',
+ category: 6,
+ description: 'my super description for pod 3',
+ tags: [ 'tag1p3' ],
+ fixture: 'video_short3.webm'
+ }
+ videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes, next)
},
function (next) {
- const name = 'my super name for pod 3-2'
- const category = 7
- const description = 'my super description for pod 3-2'
- const tags = [ 'tag2p3', 'tag3p3', 'tag4p3' ]
- const file = 'video_short.webm'
- videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {
+ name: 'my super name for pod 3-2',
+ category: 7,
+ description: 'my super description for pod 3-2',
+ tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
+ fixture: 'video_short.webm'
+ }
+ videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes, next)
},
function (next) {
setTimeout(next, 22000)
it('Should update the video 3 by asking pod 3', function (done) {
this.timeout(15000)
- const name = 'my super video updated'
- const category = 10
- const description = 'my super description updated'
- const tags = [ 'tagup1', 'tagup2' ]
-
- videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, name, category, description, tags, function (err) {
+ const attributes = {
+ name: 'my super video updated',
+ category: 10,
+ description: 'my super description updated',
+ tags: [ 'tagup1', 'tagup2' ]
+ }
+ videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes, function (err) {
if (err) throw err
setTimeout(done, 11000)
const videosUtils = require('../utils/videos')
describe('Test requests stats', function () {
+ const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ]
const path = '/api/v1/requests/stats'
let servers = []
function uploadVideo (server, callback) {
- const name = 'my super video'
- const category = 5
- const description = 'my super description'
- const tags = [ 'tag1', 'tag2' ]
- const fixture = 'video_short.webm'
+ const videoAttributes = {
+ tags: [ 'tag1', 'tag2' ]
+ }
- videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, fixture, callback)
+ videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, callback)
}
function getRequestsStats (server, callback) {
getRequestsStats(server, function (err, res) {
if (err) throw err
- const body = res.body
- expect(body.remainingMilliSeconds).to.be.at.least(0)
- expect(body.remainingMilliSeconds).to.be.at.most(10000)
+ const requestSchedulers = res.body
+ for (const requestSchedulerName of requestSchedulerNames) {
+ const requestScheduler = requestSchedulers[requestSchedulerName]
+
+ expect(requestScheduler.remainingMilliSeconds).to.be.at.least(0)
+ expect(requestScheduler.remainingMilliSeconds).to.be.at.most(10000)
+ }
done()
})
getRequestsStats(server, function (err, res) {
if (err) throw err
- const body = res.body
- expect(body.totalRequests).to.equal(1)
+ const requestSchedulers = res.body
+ const requestScheduler = requestSchedulers.requestScheduler
+ expect(requestScheduler.totalRequests).to.equal(1)
done()
})
})
it('Should upload the video', function (done) {
- this.timeout(5000)
- const name = 'my super name'
- const description = 'my super description'
- const category = 2
- const tags = [ 'tag1', 'tag2', 'tag3' ]
- const file = 'video_short.webm'
- videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, done)
+ const videoAttributes = {
+ name: 'my super name',
+ category: 2,
+ tags: [ 'tag1', 'tag2', 'tag3' ]
+ }
+ videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, done)
})
it('Should seed the uploaded video', function (done) {
'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
]
each(videos, function (video, callbackEach) {
- const name = video + ' name'
- const description = video + ' description'
- const category = 2
- const tags = [ 'tag1', 'tag2', 'tag3' ]
+ const videoAttributes = {
+ name: video + ' name',
+ description: video + ' description',
+ category: 2,
+ tags: [ 'tag1', 'tag2', 'tag3' ],
+ fixture: video
+ }
- videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, video, callbackEach)
+ videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, callbackEach)
}, done)
})
})
it('Should update a video', function (done) {
- const name = 'my super video updated'
- const category = 4
- const description = 'my super description updated'
- const tags = [ 'tagup1', 'tagup2' ]
-
- videosUtils.updateVideo(server.url, server.accessToken, videoId, name, category, description, tags, done)
+ const attributes = {
+ name: 'my super video updated',
+ category: 4,
+ description: 'my super description updated',
+ tags: [ 'tagup1', 'tagup2' ]
+ }
+ videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, done)
})
it('Should have the video updated', function (done) {
})
it('Should update only the tags of a video', function (done) {
- const tags = [ 'tag1', 'tag2', 'supertag' ]
+ const attributes = {
+ tags: [ 'tag1', 'tag2', 'supertag' ]
+ }
- videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, null, tags, function (err) {
+ videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, function (err) {
if (err) throw err
videosUtils.getVideo(server.url, videoId, function (err, res) {
})
it('Should update only the description of a video', function (done) {
- const description = 'hello everybody'
+ const attributes = {
+ description: 'hello everybody'
+ }
- videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, description, null, function (err) {
+ videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, function (err) {
if (err) throw err
videosUtils.getVideo(server.url, videoId, function (err, res) {
it('Should not be able to upload a video', function (done) {
accessToken = 'mysupertoken'
- const name = 'my super name'
- const description = 'my super description'
- const category = 5
- const tags = [ 'tag1', 'tag2' ]
- const video = 'video_short.webm'
- videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 401, done)
+ const videoAttributes = {}
+ videosUtils.uploadVideo(server.url, accessToken, videoAttributes, 401, done)
})
it('Should not be able to make friends', function (done) {
})
it('Should upload the video with the correct token', function (done) {
- const name = 'my super name'
- const category = 5
- const description = 'my super description'
- const tags = [ 'tag1', 'tag2' ]
- const video = 'video_short.webm'
- videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 204, function (err, res) {
+ const videoAttributes = {}
+ videosUtils.uploadVideo(server.url, accessToken, videoAttributes, 204, function (err, res) {
if (err) throw err
videosUtils.getVideosList(server.url, function (err, res) {
})
it('Should upload the video again with the correct token', function (done) {
- const name = 'my super name 2'
- const category = 5
- const description = 'my super description 2'
- const tags = [ 'tag1' ]
- const video = 'video_short.webm'
- videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 204, done)
+ const videoAttributes = {}
+ videosUtils.uploadVideo(server.url, accessToken, videoAttributes, 204, done)
})
it('Should retrieve a video rating', function (done) {
it('Should be able to upload a video with this user', function (done) {
this.timeout(5000)
- const name = 'my super name'
- const category = 5
- const description = 'my super description'
- const tags = [ 'tag1', 'tag2', 'tag3' ]
- const file = 'video_short.webm'
- videosUtils.uploadVideo(server.url, accessTokenUser, name, category, description, tags, file, done)
+ const videoAttributes = {}
+ videosUtils.uploadVideo(server.url, accessTokenUser, videoAttributes, done)
})
it('Should list all the users', function (done) {
},
// Upload some videos on each pods
function (next) {
- const name = 'my super name for pod 1'
- const category = 5
- const description = 'my super description for pod 1'
- const tags = [ 'tag' ]
- const file = 'video_short2.webm'
- videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {
+ name: 'my super name for pod 1',
+ description: 'my super description for pod 1'
+ }
+ videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, next)
},
function (next) {
- const name = 'my super name for pod 2'
- const category = 5
- const description = 'my super description for pod 2'
- const tags = [ 'tag' ]
- const file = 'video_short2.webm'
- videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, category, description, tags, file, next)
+ const videoAttributes = {
+ name: 'my super name for pod 2',
+ description: 'my super description for pod 2'
+ }
+ videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, next)
},
// Wait videos propagation
function (next) {
function upload (servers, numServer, callback) {
if (!callback) callback = function () {}
- const name = Date.now() + ' name'
- const category = 4
- const description = Date.now() + ' description'
- const tags = [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ]
- const file = 'video_short1.webm'
-
console.log('Uploading video to server ' + numServer)
- videosUtils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, name, category, description, tags, file, callback)
+ const videoAttributes = {
+ name: Date.now() + ' name',
+ category: 4,
+ description: Date.now() + ' description',
+ tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ],
+ fixture: 'video_short1.webm'
+ }
+ videosUtils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, videoAttributes, callback)
}
function update (servers, numServer, callback) {
if (videos.length === 0) return callback()
const toUpdate = videos[getRandomInt(0, videos.length)].id
- const name = Date.now() + ' name'
- const description = Date.now() + ' description'
- const tags = [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ]
+ const attributes = {
+ name: Date.now() + ' name',
+ description: Date.now() + ' description',
+ tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ]
+ }
console.log('Updating video of server ' + numServer)
- videosUtils.updateVideo(servers[numServer].url, servers[numServer].accessToken, toUpdate, name, description, tags, callback)
+ videosUtils.updateVideo(servers[numServer].url, servers[numServer].accessToken, toUpdate, attributes, callback)
})
}
return val.split(',')
}
-function upload (url, accessToken, name, category, description, tags, file) {
+function upload (url, accessToken, name, category, description, tags, fixture) {
console.log('Uploading %s video...', program.name)
- utils.uploadVideo(url, accessToken, name, category, description, tags, file, function (err) {
+ const videoAttributes = {
+ name,
+ category,
+ description,
+ tags,
+ fixture
+ }
+ utils.uploadVideo(url, accessToken, videoAttributes, function (err) {
if (err) throw err
console.log('Video uploaded.')
}
}
-function uploadVideo (url, accessToken, name, category, description, tags, fixture, specialStatus, end) {
+function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end) {
if (!end) {
end = specialStatus
specialStatus = 204
const path = '/api/v1/videos'
+ // Default attributes
+ let attributes = {
+ name: 'my super video',
+ category: 5,
+ description: 'my super description',
+ tags: [ 'tag' ],
+ fixture: 'video_short.webm'
+ }
+ attributes = Object.assign(attributes, videoAttributesArg)
+
const req = request(url)
.post(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
- .field('name', name)
- .field('category', category)
- .field('description', description)
+ .field('name', attributes.name)
+ .field('category', attributes.category)
+ .field('description', attributes.description)
- for (let i = 0; i < tags.length; i++) {
- req.field('tags[' + i + ']', tags[i])
+ for (let i = 0; i < attributes.tags.length; i++) {
+ req.field('tags[' + i + ']', attributes.tags[i])
}
let filepath = ''
- if (pathUtils.isAbsolute(fixture)) {
- filepath = fixture
+ if (pathUtils.isAbsolute(attributes.fixture)) {
+ filepath = attributes.fixture
} else {
- filepath = pathUtils.join(__dirname, '..', 'api', 'fixtures', fixture)
+ filepath = pathUtils.join(__dirname, '..', 'api', 'fixtures', attributes.fixture)
}
req.attach('videofile', filepath)
.end(end)
}
-function updateVideo (url, accessToken, id, name, category, description, tags, specialStatus, end) {
+function updateVideo (url, accessToken, id, attributes, specialStatus, end) {
if (!end) {
end = specialStatus
specialStatus = 204
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
- if (name) req.field('name', name)
- if (category) req.field('category', category)
- if (description) req.field('description', description)
+ if (attributes.name) req.field('name', attributes.name)
+ if (attributes.category) req.field('category', attributes.category)
+ if (attributes.description) req.field('description', attributes.description)
- if (tags) {
- for (let i = 0; i < tags.length; i++) {
- req.field('tags[' + i + ']', tags[i])
+ if (attributes.tags) {
+ for (let i = 0; i < attributes.tags.length; i++) {
+ req.field('tags[' + i + ']', attributes.tags[i])
}
}