k2hr3-api 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +12 -0
- package/bin/run.sh +61 -19
- package/package.json +3 -3
- package/tests/auto_extdata.js +2 -0
- package/tests/auto_userdata.js +15 -12
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
k2hr3-api (1.0.24) unstable; urgency=low
|
|
2
|
+
|
|
3
|
+
* Updated dependencies and test code for new chai version - #98
|
|
4
|
+
|
|
5
|
+
-- Takeshi Nakatani <ggtakec@gmail.com> Mon, 19 Jun 2023 21:09:01 +0900
|
|
6
|
+
|
|
7
|
+
k2hr3-api (1.0.23) unstable; urgency=low
|
|
8
|
+
|
|
9
|
+
* Re-fixed a bug about stopping processes in run.sh - #96
|
|
10
|
+
|
|
11
|
+
-- Takeshi Nakatani <ggtakec@gmail.com> Thu, 01 Jun 2023 19:58:08 +0900
|
|
12
|
+
|
|
1
13
|
k2hr3-api (1.0.22) unstable; urgency=low
|
|
2
14
|
|
|
3
15
|
* Fixed a bug about stopping processes in run.sh - #94
|
package/bin/run.sh
CHANGED
|
@@ -76,6 +76,44 @@ PrintUsage()
|
|
|
76
76
|
echo ""
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
#
|
|
80
|
+
# Using ALL_CHILD_PIDS global variable
|
|
81
|
+
#
|
|
82
|
+
get_all_pid_list()
|
|
83
|
+
{
|
|
84
|
+
if [ -z "${ALL_CHILD_PIDS}" ]; then
|
|
85
|
+
return 0
|
|
86
|
+
fi
|
|
87
|
+
_ADD_PIDS=0
|
|
88
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
89
|
+
if _CIHLD_PIDS=$(pgrep -P "${_ONE_PID}"); then
|
|
90
|
+
for _ONE_CPID in ${_CIHLD_PIDS}; do
|
|
91
|
+
_FOUND_PID=0
|
|
92
|
+
for _ONE_PPID in ${ALL_CHILD_PIDS}; do
|
|
93
|
+
if [ "${_ONE_CPID}" = "${_ONE_PPID}" ]; then
|
|
94
|
+
_FOUND_PID=1
|
|
95
|
+
break
|
|
96
|
+
fi
|
|
97
|
+
done
|
|
98
|
+
if [ "${_FOUND_PID}" -eq 0 ]; then
|
|
99
|
+
#
|
|
100
|
+
# Add child PID
|
|
101
|
+
#
|
|
102
|
+
ALL_CHILD_PIDS="${ALL_CHILD_PIDS} ${_ONE_CPID}"
|
|
103
|
+
_ADD_PIDS=1
|
|
104
|
+
fi
|
|
105
|
+
done
|
|
106
|
+
fi
|
|
107
|
+
done
|
|
108
|
+
if [ "${_ADD_PIDS}" -eq 1 ]; then
|
|
109
|
+
#
|
|
110
|
+
# Reentrant for check adding PIDs
|
|
111
|
+
#
|
|
112
|
+
get_all_pid_list
|
|
113
|
+
fi
|
|
114
|
+
return 0
|
|
115
|
+
}
|
|
116
|
+
|
|
79
117
|
#
|
|
80
118
|
# Stop processes
|
|
81
119
|
#
|
|
@@ -92,38 +130,42 @@ stop_old_process()
|
|
|
92
130
|
return 0
|
|
93
131
|
fi
|
|
94
132
|
|
|
95
|
-
|
|
133
|
+
ALL_CHILD_PIDS="$(tr -d '\n' < "${PROC_PID_FILE}")"
|
|
134
|
+
|
|
135
|
+
if pgrep -f "${PRGNAME}" | grep -q "${ALL_CHILD_PIDS}"; then
|
|
136
|
+
#
|
|
137
|
+
# List up all chid processes
|
|
138
|
+
#
|
|
139
|
+
get_all_pid_list
|
|
96
140
|
|
|
97
|
-
if pgrep -f "${PRGNAME}" | grep -q "${OLD_PID}"; then
|
|
98
141
|
#
|
|
99
142
|
# Try to stop(HUP) process and child processes
|
|
100
143
|
#
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
fi
|
|
144
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
145
|
+
kill -HUP "${_ONE_PID}" >/dev/null 2>&1
|
|
146
|
+
done
|
|
105
147
|
sleep 1
|
|
106
148
|
|
|
107
149
|
#
|
|
108
|
-
#
|
|
150
|
+
# If processes are running yet, try to kill it.
|
|
109
151
|
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
#
|
|
114
|
-
if ! /bin/sh -c "kill -KILL ${OLD_PID} ${OLD_CIHLD_PIDS}" >/dev/null 2>&1; then
|
|
115
|
-
echo "[WARNING] Failed to retry stop some old processes."
|
|
152
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
153
|
+
if ps -p "${_ONE_PID}" >/dev/null 2>&1; then
|
|
154
|
+
kill -KILL "${_ONE_PID}" >/dev/null 2>&1
|
|
116
155
|
fi
|
|
117
|
-
|
|
156
|
+
done
|
|
157
|
+
sleep 1
|
|
118
158
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
159
|
+
#
|
|
160
|
+
# Result
|
|
161
|
+
#
|
|
162
|
+
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
163
|
+
if ps -p "${_ONE_PID}" >/dev/null 2>&1; then
|
|
123
164
|
echo "[ERROR] Could not stop old processes."
|
|
124
165
|
return 1
|
|
125
166
|
fi
|
|
126
|
-
|
|
167
|
+
done
|
|
168
|
+
|
|
127
169
|
echo "[INFO] Stop old processes."
|
|
128
170
|
fi
|
|
129
171
|
rm -f "${PROC_PID_FILE}"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "k2hr3-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@kubernetes/client-node": "^0.18.1",
|
|
6
6
|
"body-parser": "^1.20.2",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"chai": "^4.3.7",
|
|
32
|
-
"chai-http": "^4.
|
|
33
|
-
"eslint": "^8.
|
|
32
|
+
"chai-http": "^4.4.0",
|
|
33
|
+
"eslint": "^8.43.0",
|
|
34
34
|
"mocha": "^10.2.0",
|
|
35
35
|
"nyc": "^15.1.0"
|
|
36
36
|
},
|
package/tests/auto_extdata.js
CHANGED
|
@@ -174,6 +174,7 @@ describe('API : EXTDATA', function(){ // eslint-disable-line no-undef
|
|
|
174
174
|
|
|
175
175
|
chai.request(app)
|
|
176
176
|
.get(uri)
|
|
177
|
+
.set('user-agent', '')
|
|
177
178
|
.set('content-type', 'application/octet-stream')
|
|
178
179
|
.set('user-agent', ua)
|
|
179
180
|
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
@@ -194,6 +195,7 @@ describe('API : EXTDATA', function(){ // eslint-disable-line no-undef
|
|
|
194
195
|
|
|
195
196
|
chai.request(app)
|
|
196
197
|
.get(uri)
|
|
198
|
+
.set('user-agent', '')
|
|
197
199
|
.set('content-type', 'application/octet-stream')
|
|
198
200
|
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
199
201
|
.end(function(err, res){
|
package/tests/auto_userdata.js
CHANGED
|
@@ -82,9 +82,9 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
82
82
|
expect(res.files).to.be.an('object'); // response has some files from 'multipart/mixed'
|
|
83
83
|
expect(res.files[null]).to.be.an('object'); // check only first(null) position( [TODO] checking another )
|
|
84
84
|
expect(res.files[null].size).to.be.a('number'); // file has size member
|
|
85
|
-
expect(res.files[null].
|
|
86
|
-
expect(res.files[null].
|
|
87
|
-
expect(res.files[null].
|
|
85
|
+
expect(res.files[null].filepath).to.be.an('string').to.not.empty; // file has temporary path
|
|
86
|
+
expect(res.files[null].originalFilename).to.be.an('string').to.not.empty; // file has real name
|
|
87
|
+
expect(res.files[null].mimetype).to.be.an('string').to.not.empty; // file is set 'content-type'
|
|
88
88
|
done();
|
|
89
89
|
});
|
|
90
90
|
});
|
|
@@ -109,9 +109,9 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
109
109
|
expect(res.files).to.be.an('object'); // response has some files from 'multipart/mixed'
|
|
110
110
|
expect(res.files[null]).to.be.an('object'); // check only first(null) position( [TODO] checking another )
|
|
111
111
|
expect(res.files[null].size).to.be.a('number'); // file has size member
|
|
112
|
-
expect(res.files[null].
|
|
113
|
-
expect(res.files[null].
|
|
114
|
-
expect(res.files[null].
|
|
112
|
+
expect(res.files[null].filepath).to.be.an('string').to.not.empty; // file has temporary path
|
|
113
|
+
expect(res.files[null].originalFilename).to.be.an('string').to.not.empty; // file has real name
|
|
114
|
+
expect(res.files[null].mimetype).to.be.an('string').to.not.empty; // file is set 'content-type'
|
|
115
115
|
done();
|
|
116
116
|
});
|
|
117
117
|
});
|
|
@@ -135,9 +135,9 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
135
135
|
expect(res.files).to.be.an('object'); // response has some files from 'multipart/mixed'
|
|
136
136
|
expect(res.files[null]).to.be.an('object'); // check only first(null) position( [TODO] checking another )
|
|
137
137
|
expect(res.files[null].size).to.be.a('number'); // file has size member
|
|
138
|
-
expect(res.files[null].
|
|
139
|
-
expect(res.files[null].
|
|
140
|
-
expect(res.files[null].
|
|
138
|
+
expect(res.files[null].filepath).to.be.an('string').to.not.empty; // file has temporary path
|
|
139
|
+
expect(res.files[null].originalFilename).to.be.an('string').to.not.empty; // file has real name
|
|
140
|
+
expect(res.files[null].mimetype).to.be.an('string').to.not.empty; // file is set 'content-type'
|
|
141
141
|
done();
|
|
142
142
|
});
|
|
143
143
|
});
|
|
@@ -148,6 +148,7 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
148
148
|
|
|
149
149
|
chai.request(app)
|
|
150
150
|
.get(uri)
|
|
151
|
+
.set('user-agent', '')
|
|
151
152
|
.set('content-type', 'application/octet-stream')
|
|
152
153
|
.set('accept-encoding', 'identity') // Chai send gzip encoding as default, thus we set 'identity'
|
|
153
154
|
.end(function(err, res){
|
|
@@ -167,6 +168,7 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
167
168
|
|
|
168
169
|
chai.request(app)
|
|
169
170
|
.get(uri)
|
|
171
|
+
.set('user-agent', '')
|
|
170
172
|
.set('accept-encoding', '') // Chai send gzip encoding as default, thus we set ''
|
|
171
173
|
.end(function(err, res){
|
|
172
174
|
expect(res).to.have.status(400);
|
|
@@ -191,7 +193,7 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
191
193
|
.end(function(err, res){
|
|
192
194
|
expect(res).to.have.status(200);
|
|
193
195
|
expect(res).to.be.an('object');
|
|
194
|
-
expect(res.body).
|
|
196
|
+
expect(res.body).be.instanceof(Buffer); // body is empty because it must be 'application/json'
|
|
195
197
|
expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
|
|
196
198
|
expect(res.files).to.be.a('undefined'); // files is empty because it must be 'text/plain'
|
|
197
199
|
expect(res.header).to.be.an('object'); // check response header
|
|
@@ -219,7 +221,7 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
219
221
|
.end(function(err, res){
|
|
220
222
|
expect(res).to.have.status(200);
|
|
221
223
|
expect(res).to.be.an('object');
|
|
222
|
-
expect(res.body).
|
|
224
|
+
expect(res.body).be.instanceof(Buffer); // body is empty because it must be 'application/json'
|
|
223
225
|
expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
|
|
224
226
|
expect(res.files).to.be.a('undefined'); // files is empty because it must be 'text/plain'
|
|
225
227
|
expect(res.header).to.be.an('object'); // check response header
|
|
@@ -246,7 +248,7 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
246
248
|
.end(function(err, res){
|
|
247
249
|
expect(res).to.have.status(200);
|
|
248
250
|
expect(res).to.be.an('object');
|
|
249
|
-
expect(res.body).
|
|
251
|
+
expect(res.body).be.instanceof(Buffer); // body is empty because it must be 'application/json'
|
|
250
252
|
expect(res.text).to.be.a('undefined'); // text is empty because it must be 'text/plain'
|
|
251
253
|
expect(res.files).to.be.a('undefined'); // files is empty because it must be 'text/plain'
|
|
252
254
|
expect(res.header).to.be.an('object'); // check response header
|
|
@@ -265,6 +267,7 @@ describe('API : USERDATA', function(){ // eslint-disable-line no-undef
|
|
|
265
267
|
|
|
266
268
|
chai.request(app)
|
|
267
269
|
.get(uri)
|
|
270
|
+
.set('user-agent', '')
|
|
268
271
|
.set('content-type', 'application/octet-stream')
|
|
269
272
|
.set('accept-encoding', 'gzip')
|
|
270
273
|
.end(function(err, res){
|