Commit graph

237 commits

Author SHA1 Message Date
Jake Barnby
bada1a7c05 Timing updates 2026-02-24 14:00:07 +13:00
Jake Barnby
f2759cb65a fix: remove file caching, disable --functional for Databases/Functions/Realtime
Services that depend on shared static state between test methods
(Databases, Functions, Realtime) now run without --functional flag,
so test methods execute sequentially within each class while classes
still run in parallel. All other services keep --functional mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 03:44:28 +13:00
Jake Barnby
8d18a33072 fix: call ensureSharedProject() in all setup methods, not just setupDatabase
When setupAttributes/setupIndexes/etc hit the file cache, they return
immediately without calling setupDatabase(), so ensureSharedProject()
was never called. This left self::$project empty, causing getProject()
to create a new project that didn't match the cached database IDs (404s).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 03:11:50 +13:00
Jake Barnby
a0b8437f08 fix: scope file caching to Database tests only, revert for non-Database tests
The previous file caching approach cached getRoot(), getUser(), getProject(),
and getConsoleVariables() globally. This caused all test methods in a class
to share the same project, breaking non-Database tests that expect isolated
state (Account 401s, Storage 500s, Users 404s, etc.).

Now file caching is only applied in Database/Transaction test setup chains:
- ensureSharedProject() in DatabasesBase, TransactionsBase, TransactionPermissionsBase
  creates and file-caches both the project AND user so all methods share
  consistent project + user state (needed for collection permissions)
- Non-Database tests (Account, Storage, Users, etc.) create their own
  isolated projects per-process as before

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 02:46:56 +13:00
Jake Barnby
3ea1e8e59f fix: add file-based cross-process caching for ParaTest --functional mode
With --functional mode, each test method runs in its own process so
static caches are empty. This causes every method to recreate projects,
databases, collections, attributes, and indexes - flooding the serial
database worker queue and causing attribute polling timeouts.

File-based caching with file locks ensures resources are created once
per test class, then shared across all method processes. This restores
--functional mode and dramatically reduces worker queue load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 01:47:20 +13:00
Jake Barnby
abdceb831a fix: resolve E2E test failures for screenshots, account logs, risky tests, and deployment timeouts
- Accept 404 alongside 200 for screenshot tests with custom headers/permissions (browser service CI limitation)
- Fix testGetAccountLogs to expect 1 log (session.create only, user.create audit not triggered for self-service)
- Move getSupportForOperators() check before any assertions in testOperators/testBulkOperators (PHPUnit 12 risky test fix)
- Increase deployment build/activation polling timeout from 240s to 360s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 20:43:51 +13:00
Jake Barnby
b7d503e8e9 fix: resolve MariaDB spatial attribute and index creation failures
- Replace findOne()->isEmpty() with count() > 0 in spatial check to avoid
  potential false positives when checking for existing data in empty collections
- Use waitForAllAttributes instead of waitForAttribute before spatial index
  creation to ensure the collection document cache is refreshed
- Add response assertions for attribute creation in testSpatialPolygonAttributes
  to fail fast instead of timing out for 15 minutes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 18:53:50 +13:00
Jake Barnby
f8e29c6b38 fix: prevent testTimeout from deleting shared database
testTimeout was using setupDatabase() to get the shared database, creating
a collection within it, then deleting the entire database at cleanup. This
destroyed the shared Movies/Actors/Books collections, causing testNotSearch
and other tests relying on the shared database to fail with 404.

Fix: only delete the test collection, not the shared database. Also add
waitForAttribute to prevent intermittent failures from attribute not being
available when inserting documents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 02:37:06 +13:00
Jake Barnby
fa972093f4 fix: front-load fulltext search infrastructure into cached setup chain
Move the Books collection, attributes, and fulltext index creation into
the shared setupCollection/setupAttributes/setupIndexes cache chain so
they are processed early when the worker queue is less loaded. This
eliminates testNotSearch creating redundant infrastructure from scratch
at test time when the queue is overwhelmed with 830+ parallel tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 23:26:03 +13:00
Jake Barnby
dca375624c fix: add missing 202 assertions before schema polling waits
- Fix testSpatialDistanceInMeter: move assertEquals(202) BEFORE waitForIndex
  (was after, causing misleading 4-minute timeout on creation failure)
- Add 202 assertions to testSpatialAttributesMixedCollection attribute creation
- Add 202 assertion to testConcurrentTransactionConflicts attribute creation
- Add 202 assertion to fulltext search index creation
- Add 202 assertion to shared collection attribute creation

These ensure tests fail fast with clear errors if schema creation returns
an error, instead of pointlessly polling for 4 minutes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 22:58:05 +13:00
Jake Barnby
dd1a3d8222 fix: adjust testCreateIndexes index count for MongoDB maxIndexLength=1024
MongoDB's maxIndexLength (1024) allows the 512+512 index to succeed,
resulting in 5 indexes instead of 4. Use conditional count and
assertContains for position-independent key checks.

Verified: 830/830 Database tests pass locally on MongoDB with paratest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 19:59:20 +13:00
Jake Barnby
93bc3871df fix: MongoDB test compatibility and enable JUnit XML for paratest retry
- testCreateIndexes: conditionally check index length based on adapter's maxIndexLength (MongoDB 1024 vs SQL 768)
- testConcurrentTransactionConflicts: accept both 409 and 500 since MongoDB adapter doesn't map write conflicts to ConflictException
- testEnforceCollectionPermissions: add error body to assertion for debugging
- Enable --log-junit for paratest in both project and shared mode CI jobs so itznotabug/php-retry@v3 can identify and selectively retry failing tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 19:09:01 +13:00
Jake Barnby
d6d12d818c fix: use getContainerIdResponseKey() instead of hardcoded $collectionId in upsert test
TablesDB uses $tableId not $collectionId in data payloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 16:03:46 +13:00
Jake Barnby
442a8d86d6 fix: use getRecordResource() instead of hardcoded 'documents' in testUpsertDocument
TablesDB uses 'rows' not 'documents' for the list records response key.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 15:44:41 +13:00
Jake Barnby
84c40cea41 fix: resolve testCreateAttributes, testUpsertDocument, and SchemaPolling timeouts
- Fix testCreateAttributes: use $actorsAttr instead of undefined $actors variable,
  and use $this->getSchemaResource() instead of hardcoded 'attributes' for TablesDB compat
- Fix testUpsertDocument: add missing 'data' => $upsertData in PUT request body
- Increase SchemaPolling default timeout from 60s to 120s for CI stability with
  spatial attributes under parallel load

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 15:25:45 +13:00
Jake Barnby
9796c46975 fix: misplaced assertion in testUpdateAttributeEnum and reduce timeouts
- Move maxLength/assertStringContainsString from testUpdateAttributeEnum
  back to testPatchAttribute where $attribute is defined
- Fix remaining $data['moviesId'] -> $moviesId in testCreateAttributes
- Reduce WebSocket timeout from 30s to 15s for faster failure detection
- Reduce Realtime helper assertEventually from 30s to 15s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 15:07:05 +13:00
Jake Barnby
ae4e79518b fix: remaining testCreateAttributes undefined variable references
- Change $data['moviesId'] to $moviesId at integers2 attribute creation
- Change $data['actorsId'] to $actorsId at relationship assertion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 14:59:25 +13:00
Jake Barnby
2c1919140f fix: resolve additional test failures from CI results
DatabasesBase:
- testCreateAttributes: use local $moviesId/$actorsId instead of $data['...']
- testValidateOperators: add missing setupOneToManyRelationship() call
- testSelectQueries: add missing setupOneToManyRelationship() call
- testUniqueIndexDuplicate: define missing $serverHeaders variable
- testListDocuments: change return type from array to void (no callers)

RealtimeConsoleClientTest:
- testAttributesCollectionsAPI: create database/collection before opening
  WebSocket to prevent their events from interfering with attribute events
- testAttributesTablesAPI: same restructuring for TablesDB variant

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 14:42:41 +13:00
Jake Barnby
acad17f3b8 fix: resolve test failures and reduce excessive timeouts
- DatabasesBase: fix 5 merge corruption issues (missing integers2 attr,
  undefined vars, wrong assertion, wrong setup method)
- WebhooksBase: increase deployment build timeout from 10s to 120s
- RealtimeBase: reduce WebSocket timeout 120s→30s, fix deprecated nullable
- RealtimeConsoleClientTest: reduce assertEventually 120s→30s
- SchemaPolling: reduce all default timeouts 600s→60s
- SitesBase: reduce build timeout 300s→120s, activation 200s→60s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 14:23:42 +13:00
Jake Barnby
9e628072eb fix: resolve additional merge corruptions in test files
- DatabasesBase.php: fix array indentation for 'library' key inside 'data' array
- SitesBase.php: fix corrupted while-loop/assertEventually merge in
  activation check
- DatabasesStringTypesTest.php: remove return $data from void methods,
  convert @depends chain to use setupDatabaseAndCollection()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 04:11:37 +13:00
Jake Barnby
6c29f4e285 fix: resolve merge corruptions in DatabasesBase.php from feat-db-tests merge
- Replace all hardcoded Legacy-style URLs with API-agnostic helpers
  (getContainerUrl, getSchemaUrl, getRecordUrl, getIndexUrl)
- Replace hardcoded param keys (collectionId, documentSecurity,
  relatedCollectionId, attributes) with helper methods
- Replace hardcoded response keys ($collectionId, relatedCollection)
  with getContainerIdResponseKey() and getRelatedResourceKey()
- Fix structural merge corruptions where code from different methods
  got interleaved (testCreateAttributes, testCreateIndexes,
  testGetDocumentWithQueries, testOperators, testUniqueIndexDuplicate)
- Remove orphaned code fragments and stale return statements
- Fix void methods incorrectly returning $data
- Add proper setup calls in relationship test methods
- Update composer.lock to match composer.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 03:55:39 +13:00
Jake Barnby
64a368ba3d Merge remote-tracking branch 'origin/feat-db-tests' into feat-mongodb
# Conflicts:
#	.github/workflows/tests.yml
#	src/Appwrite/Utopia/Response.php
#	src/Appwrite/Utopia/Response/Model/AttributeList.php
#	tests/e2e/Client.php
#	tests/e2e/Scopes/ProjectCustom.php
#	tests/e2e/Services/Databases/DatabasesBase.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/Transactions/TransactionsBase.php
#	tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php
#	tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php
#	tests/e2e/Services/Messaging/MessagingBase.php
#	tests/e2e/Services/Sites/SitesBase.php
#	tests/e2e/Services/Sites/SitesCustomServerTest.php
2026-02-18 03:27:23 +13:00
Jake Barnby
6efb20f44c fix: increase all schema polling default timeouts to 10 minutes
Under parallel CI load with MariaDB, attribute processing frequently
exceeds the previous 5-minute default timeout. Increased all polling
defaults (waitForAttribute, waitForAttributes, waitForAttributeCount,
waitForAllAttributes, waitForIndex, waitForAllIndexes) to 10 minutes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:50:32 +13:00
Jake Barnby
663b75bc03 fix: increase waitForAllAttributes timeout for movies collection setup
The 'integers' attribute was getting stuck in 'processing' status under
MariaDB parallel CI load, exceeding the default 5-minute timeout.
Increased to 10 minutes, matching the spatial test timeout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:36:36 +13:00
Jake Barnby
fa7ebbffa8 Fix void return in testListProjectKey and increase spatial test timeout
- Remove `return $data` from testListProjectKey() which is declared void,
  causing fatal PHP error that crashed Projects and Abuse test suites
- Increase waitForAllAttributes timeout to 10min for spatial column test
  to handle MariaDB slowness under parallel CI load

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:12:54 +13:00
Jake Barnby
2a41fc6f23 fix: Move server-side check before setupCollection in testConsoleProject
Prevents risky test warning where setupCollection makes assertions
before expectNotToPerformAssertions is called for server-side tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 19:15:35 +13:00
Jake Barnby
64d6efd098 fix: Add missing attribute types to Collection/AttributeList models and fix parallel test issues
- Add MODEL_ATTRIBUTE_VARCHAR/TEXT/MEDIUMTEXT/LONGTEXT to Collection and
  AttributeList models, fixing TypeError in Response::hasModel() that
  caused 4974 server crashes when serializing collections with new
  string attribute types
- Initialize $ruleType to null in Response::output() to prevent
  undefined variable when no model condition matches
- Isolate testUniqueIndexDuplicate with its own collection to prevent
  duplicate title interference from parallel tests in the same process
- Add retry mechanism to phone session creation for OTP token issues
- Increase GraphQL function build timeout from 30s to 120s
- Increase Sites deployment activation timeout from 100s to 200s
- Relax GraphQL bulk update row count assertion for parallel safety

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 17:53:21 +13:00
Jake Barnby
b3eecac6f9 fix: Add error details to assertions and handle 409 in relationship setup
- Add response body to assertion messages for debugging 400/409 errors
- Re-add 409 handling for relationship creation (race condition in parallel mode)
- Use explicit fullName: null instead of empty data for null person documents

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 16:56:08 +13:00
Jake Barnby
d617f89642 fix: Fix parallel test failures across Databases, GraphQL, Realtime, and Account
- DatabasesBase: Wait for twoWayKey attribute on library collection in
  setupOneToManyRelationship; use server API key headers for document creation
- DatabasesStringTypesTest: Add delays between attribute creation batches to
  avoid overwhelming the database worker
- SchemaPolling: Improve waitForAllAttributes error messaging
- GraphQL UsersTest: Use fresh user in testDeleteUserSession to avoid
  session conflicts
- Realtime: Increase WebSocket timeout to 120s and index polling to 60s
- Account: Add better error reporting for phone session creation failures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 16:08:55 +13:00
Jake Barnby
e319feb1d4 fix: Fix relationship twoWayKey, hardcoded IDs, and datetime format issues
- Set explicit twoWayKey in testOneToOneRelationship to avoid auto-generated ID
- Replace hardcoded person10/library10/11 IDs with ID::unique() in setupOneToManyRelationship
- Fix remaining datetime format comparison in testUpdateScheduledAt
- Use assertStringContainsString for Projects mock numbers excess items test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 15:28:38 +13:00
Jake Barnby
1b9d0ca1c6 fix: Fix remaining parallel-safety issues from CI iteration 2
- Fix DB relationship tests: use ID::unique() for person/library collections
- Fix DB StringTypesTest: use waitForAllAttributes instead of sleep(3)
- Fix DB permissions tests: update expected counts for parallel mode
- Fix Account OAuth tests: clean up shared mock OAuth email before use
- Fix Account phone tests: ensure phone auth enabled, unique phone numbers
- Fix Messaging: compare datetime via timestamps, accept processing state
- Fix GraphQL testGetColumn: call setupStringColumn instead of setupTable
- Fix Projects: update mock numbers error message assertion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:55:41 +13:00
Jake Barnby
161e4e53d4 fix: Address remaining parallel-safety failures across all test suites
- Fix Legacy DatabasesStringTypesTest with project-keyed setup cache
- Fix Account OTP test with unique email, phone session re-login
- Fix GraphQL setup methods with sleep, 409 handling, missing columns
- Fix Databases list/pagination tests with document ID filtering
- Fix Permissions tests with assertGreaterThanOrEqual for counts
- Fix Messaging scheduled tests to not depend on scheduler timing
- Increase Realtime WebSocket timeout to 60s and assertEventually to 30s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:20:42 +13:00
Jake Barnby
2da4211f69 fix: Make E2E tests parallel-safe for functional mode
- Fix missing return statement in DatabasesBase::testListDocuments
- Rewrite DatabasesStringTypesTest with project-keyed setup cache
- Use assertGreaterThanOrEqual in Functions testListDeployments
- Clean up OIDC provider after Account OAuth2 test
- Key all GraphQL static caches by project ID with unique IDs
- Replace sleep() with assertEventually in Realtime tests
- Increase Messaging scheduled message timeout to 180s
- Increase Sites deployment timeouts to 120s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 13:25:19 +13:00
Jake Barnby
3b025fa12a fix: Make testCreateAttributes and testCreateIndexes parallel-safe
These tests were creating resources directly in the shared collections,
which conflicts with setupAttributes() and setupIndexes() when tests
run in parallel. Now each test creates its own dedicated collection
to avoid conflicts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 18:50:36 +13:00
Jake Barnby
62e0598008 fix: Remove more invalid returns from void test methods
Removed return statements from testManyToOneRelationship and
testManyToManyRelationship which were declared as void. These
cause PHP fatal errors in PHP 8.4+.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 17:46:42 +13:00
Jake Barnby
fd0a4a0e88 fix: Remove invalid return from void testUpdateDocument method
The testUpdateDocument method was declared as void but returned [].
This causes a PHP fatal error in PHP 8.4.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 17:36:20 +13:00
Jake Barnby
e976617869 perf: Remove @depends from Databases permissions and partial GraphQL tests
- Added setupDatabase() helper with caching to all permission test files
- Removed @depends from LegacyPermissionsMemberTest, LegacyPermissionsTeamTest
- Removed @depends from TablesDBPermissionsMemberTest, TablesDBPermissionsTeamTest
- Partial GraphQL test updates from agents

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 11:56:58 +13:00
Jake Barnby
2c5dee0fdd fix: resolve test failures in Databases, Functions, Messaging, Storage
- Fix typo CLient -> Client in DatabasesBase.php:4568
- Fix typo CLient -> Client in StorageCustomClientTest.php:428
- Fix cleanupFunction() call with extra parameter in FunctionsScheduleTest.php:175
- Increase message scheduling test timeouts from 30s to 180s for CI stability

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 04:03:40 +13:00
Jake Barnby
c8d2cc090e Merge remote-tracking branch 'origin/1.8.x' into feat-db-tests
# Conflicts:
#	tests/e2e/Services/Databases/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
2026-02-06 01:29:44 +13:00
Jake Barnby
6f6ea94a19 fix: make testUpdateWithExistingRelationships self-contained
Remove @depends annotation and create a new database within the test
to fix compatibility with PHPUnit 12 and paratest parallel execution.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 01:30:52 +13:00
Jake Barnby
63b3365ce9 Fix PHPUnit 11 migration test issues
- Add missing @depends testCreateDatabase to testUpdateWithExistingRelationships in DatabasesBase.php
- Fix data provider keys in LegacyPermissionsMemberTest and TablesDBPermissionsMemberTest to match parameter names (any->anyCount, users->usersCount, doconly->docOnlyCount)
- Convert provideCustomExecutions data provider to positional arrays to avoid PHPUnit 11 named argument conflicts with @depends
- Restore @depends testUpdateAccountPhone for testCreatePhoneVerification in GraphQL AccountTest

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 18:59:53 +13:00
Jake Barnby
714b8d7ea6 Migrate to PHPUnit 11 2026-01-15 16:14:53 +13:00
Jake Barnby
f797ae3ac6 Remove sleeps 2026-01-10 14:53:29 +13:00
Jake Barnby
9498a8ba5d Consolidate, remove depends, add fixtures 2026-01-10 03:21:31 +13:00
Darshan
c5074fd52f update: move around tests. 2025-05-08 19:53:31 +05:30
Darshan
6e8dbfc674 update: documents <> rows errors. 2025-05-06 16:48:20 +05:30
Darshan
9ec897f7d6 fix: filtering 2025-05-06 12:05:06 +05:30
Darshan
9e1105b61f update: tests. 2025-05-06 11:29:56 +05:30
Darshan
75c9db8031 update: tests to use the 1.7.x changes on databases. 2025-05-05 14:07:34 +05:30
Darshan
21715448ac fix|update: database tests for new error messages. 2025-04-26 16:07:32 +05:30