Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d187bd4
feat(etag): add ETag middleware and customizable ETag generation
eiresendez Nov 26, 2024
d3e4d2e
refactor: combine ETag generation and validation into a single middle…
eiresendez Nov 28, 2024
d5dd9a8
refactor: add tests for combined ETag middleware and remove deprecate…
eiresendez Nov 28, 2024
bc39c24
test: add middleware tests for user-specific ETag generation
eiresendez Nov 28, 2024
ea9795c
Add ETag to Screen Responses
eiresendez Nov 28, 2024
924cd3c
Merge branch 'epic/FOUR-20929' into story/FOUR-20933
eiresendez Nov 29, 2024
c283de6
Merge pull request #7771 from ProcessMaker/story/FOUR-20933
eiresendez Dec 2, 2024
7d33532
Merge branch 'release-2024-fall' into epic/FOUR-20929
eiresendez Dec 2, 2024
f058177
Exclude 'active_at' field from TaskResource and requestor serializati…
eiresendez Dec 2, 2024
48cd7d6
Implement ETag Caching for Task Responses
eiresendez Dec 2, 2024
8b327c8
restrict ETag handling to GET/HEAD and enforce user-specific caching
eiresendez Dec 3, 2024
dae2468
Add ETag middleware to API group to support package routes
eiresendez Dec 5, 2024
8a94369
Apply ETag middleware to v1.1 routes for consistent caching
eiresendez Dec 5, 2024
d748403
feat: add flexibility to ETag generation with sources
eiresendez Dec 5, 2024
cdaa80d
add ETag middleware to startProcesses route
eiresendez Dec 6, 2024
e64f7a7
Merge pull request #7786 from ProcessMaker/story/FOUR-20944
eiresendez Dec 6, 2024
da5ba5d
Add detailed ETag implementation and testing documentation
eiresendez Dec 10, 2024
33fe4f6
Add ETag cache invalidation tests
eiresendez Dec 11, 2024
428b0ee
Enhance ETag middleware to log dynamic endpoint detection
eiresendez Dec 12, 2024
24afdfc
Merge pull request #7817 from ProcessMaker/story/FOUR-20950
eiresendez Dec 13, 2024
f28fcb5
Add configuration support for ETag logging and caching
eiresendez Dec 16, 2024
4e7afdc
Add ETag response time comparison for 200 vs 304
eiresendez Dec 17, 2024
d590373
Add ETag history tracking to detect dynamic endpoints
eiresendez Dec 17, 2024
8086a78
Add long-duration test to validate ETag stability under sustained load
eiresendez Dec 17, 2024
c295567
Merge pull request #7834 from ProcessMaker/story/FOUR-20954
eiresendez Dec 18, 2024
a6b7ee0
Merge branch 'release-2025-winter' into epic/FOUR-20929
eiresendez Jan 23, 2025
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
Prev Previous commit
Next Next commit
Add ETag history tracking to detect dynamic endpoints
- Implemented tracking of ETag values for specified endpoints
- Added logic to identify dynamic endpoints when ETag history shows diff values
  • Loading branch information
eiresendez committed Dec 17, 2024
commit d590373592d4096bb8dcc2e18555cb753b2e9ad1
61 changes: 61 additions & 0 deletions tests/k6/etag/detect-dynamic-endpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import http from 'k6/http';

export let options = {
vus: 1,
iterations: 5, // n iterations per URL.
};

const token = 'fake-jwt';
const endpoints = [
'https://processmaker.test/api/1.0/requests?page=1&per_page=15&include=process%2Cparticipants%2CactiveTasks%2Cdata&pmql=%28requester%20%3D%20%22admin%22%29&filter=&order_by=id&order_direction=DESC&advanced_filter=%5B%7B%22subject%22%3A%7B%22type%22%3A%22Status%22%7D%2C%22operator%22%3A%22%3D%22%2C%22value%22%3A%22In%20Progress%22%7D%5D'
];

// Object to track ETag history for each endpoint.
const etagHistory = {};

// Limit to determine when an endpoint is considered dynamic.
const ETAG_HISTORY_LIMIT = 5;

export default function () {
const headers = {
Authorization: `Bearer ${token}`,
};

endpoints.forEach((url) => {
const res1 = http.get(url, { headers });
const etag = res1.headers['Etag'];

// If no ETag is present, log a warning and skip further processing.
if (!etag) {
console.log(`No ETag found for ${url}`);
return;
}

// Log the ETag value for debugging.
console.log(`ETag: ${etag}`);

// Initialize the ETag history for this endpoint if not already present.
if (!etagHistory[url]) {
etagHistory[url] = [];
}

// Add the ETag to the history if it is unique.
if (!etagHistory[url].includes(etag)) {
etagHistory[url].push(etag);
}

// Keep the history limited to the last N ETags.
if (etagHistory[url].length > ETAG_HISTORY_LIMIT) {
etagHistory[url].shift(); // Remove the oldest ETag
}

// Check if the endpoint is dynamic.
// If the history is full and all ETags are unique, the endpoint is considered dynamic.
if (
etagHistory[url].length === ETAG_HISTORY_LIMIT &&
new Set(etagHistory[url]).size === ETAG_HISTORY_LIMIT
) {
console.log(`Dynamic endpoint detected: ${url}`);
}
});
}