#19352 Video explaining code changes: https://www.loom.com/share/370200a276b84aa388effd6ebd762e01?sid=038508c4-f3c2-40c0-baf6-6b6df682d1f0 In maintenance windows using Google Calendar, calendar event is now recreated within 30 seconds if deleted or moved to the past. - Added new endpoint for Google Calendar: `/api/_version_/fleet/calendar/webhook/{event_uuid}` - Added UUID to `calendar_events` table to make webhook lookup more efficient - webhook endpoint will only recreate event if needed -- it will not fire webhook. Webhook is still done by the cron job. # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes:
1.5 KiB
Helper methods for Google calendar
To delete all downtime events from a Google Calendar, use delete-events/delete-events.go
To move all downtime events from multiple Google Calendars to a specific time, use move-events/move-events.go
To use the helper scripts, you must set FLEET_TEST_GOOGLE_CALENDAR_SERVICE_EMAIL and FLEET_TEST_GOOGLE_CALENDAR_PRIVATE_KEY environment variables. The email is the client_email from JSON key file. The private key also comes from JSON key file for the service account, and starts with -----BEGIN PRIVATE KEY-----.
Calendar server for load testing
Test calendar server that provides a REST API for managing events. Since we may not have access to a real calendar server (such as Google Calendar API), this server will be used to test the calendar feature during load testing.
Start the server like:
go run calendar.go --port 8083 --db ./calendar.db
The server uses a SQLite database to store events. This database can be modified during testing.
On the fleet server, configure Google Calendar API key where client_email is the specified value and the private_key is the base URL of the calendar server:
{
"client_email": "calendar-load@example.com",
"private_key": "http://localhost:8083"
}
Useful tricks
To update all the events in SQLite database to start at the current time, do SQL query:
UPDATE events SET start = unixepoch('now'), end = unixepoch('now', '+30 minutes');