Skip to content

Commit c5751f3

Browse files
authored
feat(deps): upgrade plt and wattpm (#29)
* feat(deps): upgrade plt and wattpm Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com> * update Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com> --------- Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
1 parent 47dc0c4 commit c5751f3

File tree

12 files changed

+772
-830
lines changed

12 files changed

+772
-830
lines changed

package-lock.json

Lines changed: 727 additions & 770 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"start": "wattpm start"
88
},
99
"dependencies": {
10-
"@platformatic/composer": "^2.35.1",
11-
"@platformatic/runtime": "^2.35.1",
12-
"wattpm": "^2.35.1"
10+
"@platformatic/composer": "^2.52.0",
11+
"@platformatic/runtime": "^2.52.0",
12+
"wattpm": "^2.52.0"
1313
},
1414
"workspaces": [
1515
"web/*",

watt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://schemas.platformatic.dev/wattpm/2.35.1.json",
2+
"$schema": "https://schemas.platformatic.dev/wattpm/2.52.0.json",
33
"server": {
44
"hostname": "127.0.0.1",
55
"port": "{PORT}"

web/backend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
},
1111
"devDependencies": {
1212
"@fastify/type-provider-json-schema-to-ts": "^5.0.0",
13-
"@platformatic/service": "^2.35.1",
13+
"@platformatic/service": "^2.52.0",
1414
"borp": "^0.19.0",
1515
"eslint": "^9.17.0",
1616
"fastify": "^5.0.0",
1717
"fastify-tsconfig": "^2.0.0",
1818
"neostandard": "^0.12.0",
1919
"typescript": "^5.5.4",
20-
"wattpm": "^2.35.1"
20+
"wattpm": "^2.52.0"
2121
},
2222
"dependencies": {
23-
"@platformatic/control": "^2.35.1"
23+
"@platformatic/control": "^2.52.0"
2424
}
2525
}

web/backend/platformatic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://schemas.platformatic.dev/@platformatic/service/2.35.1.json",
2+
"$schema": "https://schemas.platformatic.dev/@platformatic/service/2.52.0.json",
33
"service": {
44
"openapi": true
55
},

web/backend/plugins/metrics.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ export default async function (fastify: FastifyInstance) {
151151
for (const metricValue of metric.values) {
152152
const data = metricValue.value * 1000
153153
if (data > 0) {
154-
// FIXME: update type returned by `@platformatic/control` and return also QuantileLabel inside `labels`
155-
type QuantileLabel = { quantile?: number }
156-
if ((metricValue.labels as QuantileLabel)?.quantile === 0.9) {
154+
if (metricValue.labels?.quantile === 0.9) {
157155
countP90++
158156
sumP90 += data
159157
serviceLatencyData.p90 = sumP90 / countP90
@@ -162,7 +160,7 @@ export default async function (fastify: FastifyInstance) {
162160
aggregatedSumP90 += data
163161
aggregatedLatencyData.p90 = aggregatedSumP90 / aggregatedCountP90
164162
}
165-
if ((metricValue.labels as QuantileLabel)?.quantile === 0.95) {
163+
if (metricValue.labels?.quantile === 0.95) {
166164
countP95++
167165
sumP95 += data
168166
serviceLatencyData.p95 = sumP95 / countP95
@@ -171,7 +169,7 @@ export default async function (fastify: FastifyInstance) {
171169
aggregatedSumP95 += data
172170
aggregatedLatencyData.p95 = aggregatedSumP95 / aggregatedCountP95
173171
}
174-
if ((metricValue.labels as QuantileLabel)?.quantile === 0.99) {
172+
if (metricValue.labels?.quantile === 0.99) {
175173
countP99++
176174
sumP99 += data
177175
serviceLatencyData.p99 = sumP99 / countP99

web/backend/routes/root.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,17 @@ export default async function (fastify: FastifyInstance) {
6666
return api.getRuntimeOpenapi(pid, serviceId)
6767
})
6868

69-
typedFastify.post('/runtimes/:pid/reload', {
70-
schema: {
71-
params: { type: 'object', properties: { pid: { type: 'number' } }, required: ['pid'] }
72-
}
73-
}, async (request) => {
74-
return api.reloadRuntime(request.params.pid)
75-
})
76-
7769
typedFastify.post('/runtimes/:pid/restart', {
7870
schema: {
7971
params: { type: 'object', properties: { pid: { type: 'number' } }, required: ['pid'] }
8072
}
8173
}, async (request) => {
82-
return api.restartRuntime(request.params.pid)
74+
try {
75+
await api.restartRuntime(request.params.pid)
76+
} catch (err) {
77+
// TODO: restart is currently not working. Apparently, the call to `this.start()` on `@platformatic/runtime/lib/runtime.js` fails. Once it will be fixed, we can remove the catch and the warning log (and leave the function throw as it was before). Monitor this issue to check if it's fixed or not (https://github.com/platformatic/platformatic/issues/3928)
78+
fastify.log.warn({ err }, 'Issue restarting the runtime')
79+
}
8380
})
8481

8582
typedFastify.post('/runtimes/:pid/stop', {

web/backend/test/routes/root.test.ts

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
77
test('no runtime running', async (t) => {
88
const server = await getServer(t)
99
const res = await server.inject({
10-
url: '/runtimes'
10+
url: '/runtimes?includeAdmin=true'
1111
})
1212
assert.strictEqual(res.statusCode, 200)
1313
assert.deepStrictEqual(res.json(), [], 'with no runtime running')
@@ -23,13 +23,12 @@ test('runtime is running', async (t) => {
2323
await startWatt(t)
2424
const server = await getServer(t)
2525
const res = await server.inject({
26-
url: '/runtimes'
26+
url: '/runtimes?includeAdmin=true'
2727
})
2828
assert.strictEqual(res.statusCode, 200, 'runtimes endpoint')
2929
const [runtime] = res.json()
3030
const runtimePid = runtime.pid
31-
assert.strictEqual(runtime.packageName, 'backend')
32-
assert.strictEqual(typeof runtime.packageName, 'string')
31+
assert.strictEqual(runtime.packageName, 'watt-admin')
3332
assert.strictEqual(typeof runtimePid, 'number')
3433
assert.strictEqual(runtime.packageVersion, null)
3534

@@ -45,8 +44,8 @@ test('runtime is running', async (t) => {
4544
assert.strictEqual(services.statusCode, 200, 'services endpoint')
4645
const servicesJson = services.json()
4746
assert.strictEqual(servicesJson.production, true)
48-
assert.strictEqual(servicesJson.entrypoint, 'backend')
49-
assert.strictEqual(typeof servicesJson.services[0].url, 'string')
47+
assert.strictEqual(servicesJson.entrypoint, 'composer')
48+
assert.strictEqual(typeof servicesJson.services[0].localUrl, 'string')
5049
assert.strictEqual(typeof servicesJson.services[0].entrypoint, 'boolean')
5150

5251
// Wait for the interval to be run
@@ -101,25 +100,6 @@ test('runtime is running', async (t) => {
101100
responses: { 200: { description: 'Default Response' } },
102101
},
103102
})
104-
assert.deepEqual(json.paths['/runtimes/{pid}/reload'], {
105-
post: {
106-
parameters: [
107-
{
108-
schema: {
109-
type: 'number',
110-
},
111-
in: 'path',
112-
name: 'pid',
113-
required: true,
114-
},
115-
],
116-
responses: {
117-
200: {
118-
description: 'Default Response',
119-
},
120-
},
121-
},
122-
})
123103

124104
const serviceInvalidOpenapi = await server.inject({
125105
url: `/runtimes/${runtimePid}/openapi/fantozzi`
@@ -132,18 +112,18 @@ test('runtime is running', async (t) => {
132112
})
133113
assert.strictEqual(logs.statusCode, 200)
134114

135-
const [starting, listening, started, platformatic] = logs.body.trim().split('\n')
136-
assert.ok(starting.includes('Starting the service'))
137-
assert.ok(listening.includes('Server listening at http://127.0.0.1'))
138-
assert.ok(started.includes('Started the service'))
139-
assert.ok(platformatic.includes('Platformatic is now listening at http://127.0.0.1'))
115+
const [starting, listening, started, platformatic] = logs.body.trim().split('\n').filter(val => !val.includes('Loading envfile'))
116+
assert.ok(starting.includes('Starting the service \\"backend\\"'))
117+
assert.ok(listening.includes('Started the service \\"backend\\"'))
118+
assert.ok(started.includes('Starting the service \\"frontend\\"'))
119+
assert.ok(platformatic.includes('Started the service \\"frontend\\"'))
140120
})
141121

142-
test('runtime start & stop', async (t) => {
122+
test('runtime restart', async (t) => {
143123
await startWatt(t)
144124
const server = await getServer(t)
145125
const res = await server.inject({
146-
url: '/runtimes'
126+
url: '/runtimes?includeAdmin=true'
147127
})
148128
const [{ pid }] = res.json()
149129
assert.ok(pid > 0)
@@ -153,6 +133,16 @@ test('runtime start & stop', async (t) => {
153133
url: `/runtimes/${pid}/restart`
154134
})
155135
assert.strictEqual(restart.statusCode, 200)
136+
})
137+
138+
test('runtime stop', async (t) => {
139+
await startWatt(t)
140+
const server = await getServer(t)
141+
const res = await server.inject({
142+
url: '/runtimes?includeAdmin=true'
143+
})
144+
const [{ pid }] = res.json()
145+
assert.ok(pid > 0)
156146

157147
const { statusCode } = await server.inject({
158148
method: 'POST',
@@ -167,7 +157,7 @@ test('runtime start & stop', async (t) => {
167157
assert.strictEqual(stop.statusCode, 500, 'trying to run stop command to a closed runtime')
168158

169159
const runtimes = await server.inject({
170-
url: '/runtimes'
160+
url: '/runtimes?includeAdmin=true'
171161
})
172162
assert.deepEqual(runtimes.json(), [], 'no runtime running')
173163
})

web/composer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"typescript": "^5.5.4"
1313
},
1414
"dependencies": {
15-
"@platformatic/composer": "^2.35.1"
15+
"@platformatic/composer": "^2.52.0"
1616
}
1717
}

web/composer/platformatic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://schemas.platformatic.dev/@platformatic/composer/2.35.1.json",
2+
"$schema": "https://schemas.platformatic.dev/@platformatic/composer/2.52.0.json",
33
"composer": {
44
"services": [
55
{

0 commit comments

Comments
 (0)