Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test HEAD requests. CheckerNetwork/spark#104 #521

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const createMeasurement = async (req, res, client) => {
validate(measurement, 'timeout', { type: 'boolean', required: false })
validate(measurement, 'startAt', { type: 'date', required: false })
validate(measurement, 'statusCode', { type: 'number', required: false })
validate(measurement, 'headStatusCode', { type: 'number', required: false })
validate(measurement, 'firstByteAt', { type: 'date', required: false })
validate(measurement, 'endAt', { type: 'date', required: false })
validate(measurement, 'byteLength', { type: 'number', required: false })
Expand Down Expand Up @@ -112,6 +113,7 @@ const createMeasurement = async (req, res, client) => {
timeout,
start_at,
status_code,
head_status_code,
first_byte_at,
end_at,
byte_length,
Expand All @@ -125,7 +127,7 @@ const createMeasurement = async (req, res, client) => {
completed_at_round
)
SELECT
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20,
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21,
id as completed_at_round
FROM spark_rounds
ORDER BY id DESC
Expand All @@ -142,6 +144,7 @@ const createMeasurement = async (req, res, client) => {
measurement.timeout || false,
parseOptionalDate(measurement.startAt),
measurement.statusCode,
measurement.headStatusCode,
parseOptionalDate(measurement.firstByteAt),
parseOptionalDate(measurement.endAt),
measurement.byteLength,
Expand Down Expand Up @@ -182,6 +185,7 @@ const getMeasurement = async (req, res, client, measurementId) => {
timeout: resultRow.timeout,
startAt: resultRow.start_at,
statusCode: resultRow.status_code,
headStatusCode: resultRow.head_status_code,
firstByteAt: resultRow.first_byte_at,
endAt: resultRow.end_at,
byteLength: resultRow.byte_length,
Expand Down
2 changes: 2 additions & 0 deletions api/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const VALID_MEASUREMENT = {
participantAddress,
startAt: new Date(),
statusCode: 200,
headStatusCode: 200,
firstByteAt: new Date(),
endAt: new Date(),
byteLength: 100,
Expand Down Expand Up @@ -167,6 +168,7 @@ describe('Routes', () => {
measurement.startAt.toJSON()
)
assert.strictEqual(measurementRow.status_code, measurement.statusCode)
assert.strictEqual(measurementRow.head_status_code, measurement.headStatusCode)
assert.strictEqual(
measurementRow.first_byte_at.toJSON(),
measurement.firstByteAt.toJSON()
Expand Down
1 change: 1 addition & 0 deletions migrations/065.do.head-status-code.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE measurements ADD COLUMN head_status_code INTEGER;
1 change: 1 addition & 0 deletions publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const publish = async ({
timeout,
start_at,
status_code,
head_status_code,
first_byte_at,
end_at,
byte_length,
Expand Down
4 changes: 3 additions & 1 deletion publish/test/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const insertMeasurement = async (client, measurement) => {
timeout,
start_at,
status_code,
head_status_code,
first_byte_at,
end_at,
byte_length,
Expand All @@ -30,7 +31,7 @@ export const insertMeasurement = async (client, measurement) => {
completed_at_round
)
VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21
)
`, [
measurement.sparkVersion,
Expand All @@ -42,6 +43,7 @@ export const insertMeasurement = async (client, measurement) => {
measurement.timeout,
measurement.startAt,
measurement.statusCode,
measurement.headStatusCode,
measurement.firstByteAt,
measurement.endAt,
measurement.byteLength,
Expand Down