Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
keeleliin-wrapper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
keeleliin
keeleliin-wrapper
Commits
97ab1cc8
Commit
97ab1cc8
authored
Mar 02, 2019
by
Indrek Jentson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Runtime-check teenusele lisatud serveri ühenduse kontroll
Signed-off-by:
Indrek Jentson
<
indrek.jentson@ut.ee
>
parent
af3f34b9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
49 deletions
+31
-49
controllers/api/v1/check.js
controllers/api/v1/check.js
+7
-0
package.json
package.json
+1
-1
src/service/checkService.js
src/service/checkService.js
+15
-0
src/service/integration/installService.js
src/service/integration/installService.js
+1
-0
src/service/wrapperService.js
src/service/wrapperService.js
+1
-1
test/integration/payload.js
test/integration/payload.js
+6
-47
No files found.
controllers/api/v1/check.js
View file @
97ab1cc8
...
...
@@ -33,6 +33,13 @@ router.get('/', function(req, res) {
logger
.
debug
(
'
msg:
'
+
JSON
.
stringify
(
msg
));
results
.
push
(
msg
);
return
results
;
}).
then
(
function
(
results
){
logger
.
debug
(
'
check 4
'
);
return
checker
.
checkServer
();
}).
then
(
function
(
msg
){
logger
.
debug
(
'
msg:
'
+
JSON
.
stringify
(
msg
));
results
.
push
(
msg
);
return
results
;
}).
then
(
function
(
results
){
logger
.
debug
(
'
publish, R is
'
+
(
results
?
results
.
length
:
'
?
'
));
logger
.
debug
(
'
results:
'
+
(
results
?
JSON
.
stringify
(
results
):
'
?
'
))
...
...
package.json
View file @
97ab1cc8
{
"name"
:
"keeleliin-wrapper-service"
,
"version"
:
"1.1.
1
"
,
"version"
:
"1.1.
2
"
,
"private"
:
true
,
"scripts"
:
{
"start"
:
"node ./app.js"
,
...
...
src/service/checkService.js
View file @
97ab1cc8
...
...
@@ -73,6 +73,21 @@ var CheckService = function(){
});
}
this
.
checkServer
=
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
try
{
request
.
get
(
config
.
serverUrl
+
'
:3000
'
,
function
(
err
,
replay
)
{
if
(
err
)
resolve
({
type
:
'
ERR
'
,
msg
:
'
ühendus serveriga
'
+
config
.
serverUr
+
'
ei tööta:
'
+
err
});
else
{
resolve
({
type
:
'
OK
'
,
msg
:
'
ühendus serveriga
'
+
config
.
serverUr
+
'
töötab
'
});
}
});
}
catch
(
err
)
{
resolve
({
type
:
'
ERR
'
,
msg
:
err
.
message
});
}
});
}
this
.
checkTemplate
=
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
try
{
...
...
src/service/integration/installService.js
View file @
97ab1cc8
...
...
@@ -17,6 +17,7 @@ var InstallService = function() {
}
var
messages
=
[];
logger
.
debug
(
config
.
integration
);
async
.
each
(
config
.
integration
,
function
(
serverConf
,
innerCb
)
{
...
...
src/service/wrapperService.js
View file @
97ab1cc8
...
...
@@ -27,7 +27,7 @@ function WrapperService() {
}
sessionService
.
closeSession
(
session
,
function
(
err
,
session
)
{
logger
.
debug
(
'
Sessioon on lõpetanud ja savestatud. isAsync:
'
+
session
.
isAsync
);
logger
.
debug
(
'
Sessioon on lõpetanud ja sa
l
vestatud. isAsync:
'
+
session
.
isAsync
);
if
(
session
.
isAsync
===
false
)
{
logger
.
debug
(
'
Send response
'
);
if
(
err
){
...
...
test/integration/payload.js
View file @
97ab1cc8
...
...
@@ -19,7 +19,7 @@ describe('Services', function() {
buildData
=
function
(
body
,
fileName
)
{
var
form
=
{};
form
[
'
body
'
]
=
body
;
form
[
'
body
'
]
=
JSON
.
stringify
(
body
)
;
var
file
=
{
key
:
'
content
'
,
path
:
fileName
};
var
attachment
=
fs
.
createReadStream
(
fileName
);
...
...
@@ -50,13 +50,13 @@ describe('Services', function() {
var
tmpPath
=
config
.
fs
.
tmpPath
;
var
source
=
tmpPath
+
'
/test.txt
'
;
fs
.
writeFileSync
(
source
,
'
Faili sisu
'
);
var
formData
=
buildData
(
JSON
.
stringify
(
body
)
,
source
);
var
formData
=
buildData
(
body
,
source
);
request
.
post
({
"
url
"
:
url
+
'
/api/v1/service
'
,
formData
:
formData
},
function
(
err
,
res
,
body
)
{
if
(
err
)
{
throw
err
;
}
// console.log('
res: '+JSON.stringify(res));
console
.
log
(
'
sync
res:
'
+
JSON
.
stringify
(
res
));
var
body
=
JSON
.
parse
(
res
.
body
);
body
.
response
.
should
.
have
.
property
(
'
success
'
);
body
.
response
.
success
.
should
.
equal
(
true
);
...
...
@@ -78,61 +78,20 @@ describe('Services', function() {
var
tmpPath
=
config
.
fs
.
tmpPath
;
var
source
=
tmpPath
+
'
/test.txt
'
;
fs
.
writeFileSync
(
source
,
'
Faili sisu
'
);
var
formData
=
buildData
(
JSON
.
stringify
(
body
),
source
);
var
formData
=
buildData
(
body
,
source
);
console
.
log
(
'
async form:
'
+
JSON
.
stringify
(
formData
));
request
.
post
({
"
url
"
:
url
+
'
/api/v1/service
'
,
formData
:
formData
},
function
(
err
,
res
,
body
)
{
if
(
err
)
{
throw
err
;
}
// console.log('
res: '+JSON.stringify(res));
console
.
log
(
'
async
res:
'
+
JSON
.
stringify
(
res
));
var
body
=
JSON
.
parse
(
res
.
body
);
body
.
response
.
should
.
have
.
property
(
'
success
'
);
body
.
response
.
success
.
should
.
equal
(
true
);
done
();
});
/*
request(url)
.post('/api/v1/service')
.field('body', body)
.attach('files', source)
.expect('Content-Type', /json/)
.expect(200) //Status code
.end(function(err,res) {
if (err) {
throw err;
}
res.body.should.have.property('success');
if (res.body.success) {
res.body.should.have.property('response');
res.body.response.should.have.property('sessionId');
res.body.response.message.should.equal('RUNNING');
res.body.response.should.not.have.property('pipecontent');
var sessionId = res.body.response.serviceId;
setTimeout(function () {
request(url)
.get('/api/v1/service/' + sessionId)
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) {
throw err;
}
res.body.should.not.have.property('errors');
res.body.response.message.should.equal('OK');
res.body.response.should.have.property('pipecontent');
done();
});
}, 5000);
} else {
console.log('THIS is NOT working :(');
done()
};
});
*/
});
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment