mattermost/server/tests
Jesse Hallam 41e5c7286b
Remove vestigial MySQL support (#34865)
* Remove legacy quoteColumnName() utility

Since Mattermost only supports PostgreSQL, the quoteColumnName() helper
that was designed to handle database-specific column quoting is no longer
needed. The function was a no-op that simply returned the column name
unchanged.

Remove the function from utils.go and update status_store.go to use
the "Manual" column name directly.

* Remove legacy driver checks from store.go

Since Mattermost only supports PostgreSQL, remove conditional checks
for different database drivers:

- Simplify specialSearchChars() to always return PostgreSQL-compatible chars
- Remove driver check from computeBinaryParam()
- Remove driver check from computeDefaultTextSearchConfig()
- Simplify GetDbVersion() to use PostgreSQL syntax directly
- Remove switch statement from ensureMinimumDBVersion()
- Remove unused driver parameter from versionString()

* Remove MySQL alternatives for batch delete operations

Since Mattermost only supports PostgreSQL, remove the MySQL-specific
DELETE...LIMIT syntax and keep only the PostgreSQL array-based approach:

- reaction_store.go: Use PostgreSQL array syntax for PermanentDeleteBatch
- file_info_store.go: Use PostgreSQL array syntax for PermanentDeleteBatch
- preference_store.go: Use PostgreSQL tuple IN subquery for DeleteInvalidVisibleDmsGms

* Remove MySQL alternatives for UPDATE...FROM syntax

Since Mattermost only supports PostgreSQL, remove the MySQL-specific
UPDATE syntax that joins tables differently:

- thread_store.go: Use PostgreSQL UPDATE...FROM syntax in
  MarkAllAsReadByChannels and MarkAllAsReadByTeam
- post_store.go: Use PostgreSQL UPDATE...FROM syntax in deleteThreadFiles

* Remove MySQL alternatives for JSON and subquery operations

Since Mattermost only supports PostgreSQL, remove the MySQL-specific
JSON and subquery syntax:

- thread_store.go: Use PostgreSQL JSONB operators for updating participants
- access_control_policy_store.go: Use PostgreSQL JSONB @> operator for
  querying JSON imports
- session_store.go: Use PostgreSQL subquery syntax for Cleanup
- job_store.go: Use PostgreSQL subquery syntax for Cleanup

* Remove MySQL alternatives for CTE queries

Since Mattermost only supports PostgreSQL, simplify code that
uses CTEs (Common Table Expressions):

- channel_store.go: Remove MySQL CASE-based fallback in
  UpdateLastViewedAt and use PostgreSQL CTE exclusively
- draft_store.go: Remove driver checks in DeleteEmptyDraftsByCreateAtAndUserId,
  DeleteOrphanDraftsByCreateAtAndUserId, and determineMaxDraftSize

* Remove driver checks in migrate.go and schema_dump.go

Simplify migration code to use PostgreSQL driver directly since
PostgreSQL is the only supported database.

* Remove driver checks in sqlx_wrapper.go

Always apply lowercase named parameter transformation since PostgreSQL
is the only supported database.

* Remove driver checks in user_store.go

Simplify user store functions to use PostgreSQL-only code paths:
- Remove isPostgreSQL parameter from helper functions
- Use LEFT JOIN pattern instead of subqueries for bot filtering
- Always use case-insensitive LIKE with lower() for search
- Remove MySQL-specific role filtering alternatives

* Remove driver checks in post_store.go

Simplify post_store.go to use PostgreSQL-only code paths:
- Inline getParentsPostsPostgreSQL into getParentsPosts
- Use PostgreSQL TO_CHAR/TO_TIMESTAMP for date formatting in analytics
- Use PostgreSQL array syntax for batch deletes
- Simplify determineMaxPostSize to always use information_schema
- Use PostgreSQL jsonb subtraction for thread participants
- Always execute RefreshPostStats (PostgreSQL materialized views)
- Use materialized views for AnalyticsPostCountsByDay
- Simplify AnalyticsPostCountByTeam to always use countByTeam

* Remove driver checks in channel_store.go

Simplify channel_store.go to use PostgreSQL-only code paths:
- Always use sq.Dollar.ReplacePlaceholders for UNION queries
- Use PostgreSQL LEFT JOIN for retention policy exclusion
- Use PostgreSQL jsonb @> operator for access control policy imports
- Simplify buildLIKEClause to always use LOWER() for case-insensitive search
- Simplify buildFulltextClauseX to always use PostgreSQL to_tsvector/to_tsquery
- Simplify searchGroupChannelsQuery to use ARRAY_TO_STRING/ARRAY_AGG

* Remove driver checks in file_info_store.go

Simplify file_info_store.go to use PostgreSQL-only code paths:
- Always use PostgreSQL to_tsvector/to_tsquery for file search
- Use file_stats materialized view for CountAll()
- Use file_stats materialized view for GetStorageUsage() when not including deleted
- Always execute RefreshFileStats() for materialized view refresh

* Remove driver checks in attributes_store.go

Simplify attributes_store.go to use PostgreSQL-only code paths:
- Always execute RefreshAttributes() for materialized view refresh
- Remove isPostgreSQL parameter from generateSearchQueryForExpression
- Always use PostgreSQL LOWER() LIKE LOWER() syntax for case-insensitive search

* Remove driver checks in retention_policy_store.go

Simplify retention_policy_store.go to use PostgreSQL-only code paths:
- Remove isPostgres parameter from scanRetentionIdsForDeletion
- Always use pq.Array for scanning retention IDs
- Always use pq.Array for inserting retention IDs
- Remove unused json import

* Remove driver checks in property stores

Simplify property_field_store.go and property_value_store.go to use
PostgreSQL-only code paths:
- Always use PostgreSQL type casts (::text, ::jsonb, ::bigint, etc.)
- Remove isPostgres variable and conditionals

* Remove driver checks in channel_member_history_store.go

Simplify PermanentDeleteBatch to use PostgreSQL-only code path:
- Always use ctid-based subquery for DELETE with LIMIT

* Remove remaining driver checks in user_store.go

Simplify user_store.go to use PostgreSQL-only code paths:
- Use LEFT JOIN for bot exclusion in AnalyticsActiveCountForPeriod
- Use LEFT JOIN for bot exclusion in IsEmpty

* Simplify fulltext search by consolidating buildFulltextClause functions

Remove convertMySQLFullTextColumnsToPostgres and consolidate
buildFulltextClause and buildFulltextClauseX into a single function
that takes variadic column arguments and returns sq.Sqlizer.

* Simplify SQL stores leveraging PostgreSQL-only support

- Simplify UpdateMembersRole in channel_store.go and team_store.go
  to use UPDATE...RETURNING instead of SELECT + UPDATE
- Simplify GetPostReminders in post_store.go to use DELETE...RETURNING
- Simplify DeleteOrphanedRows queries by removing MySQL workarounds
  for subquery locking issues
- Simplify UpdateUserLastSyncAt to use UPDATE...FROM...RETURNING
  instead of fetching user first then updating
- Remove MySQL index hint workarounds in ORDER BY clauses
- Update outdated comments referencing MySQL
- Consolidate buildFulltextClause and remove convertMySQLFullTextColumnsToPostgres

* Remove MySQL-specific test artifacts

- Delete unused MySQLStopWords variable and stop_word.go file
- Remove redundant testSearchEmailAddressesWithQuotes test
  (already covered by testSearchEmailAddresses)
- Update comment that referenced MySQL query planning

* Remove MySQL references from server code outside sqlstore

- Update config example and DSN parsing docs to reflect PostgreSQL-only support
- Remove mysql:// scheme check from IsDatabaseDSN
- Simplify SanitizeDataSource to only handle PostgreSQL
- Remove outdated MySQL comments from model and plugin code

* Remove MySQL references from test files

- Update test DSNs to use PostgreSQL format
- Remove dead mysql-replica flag and replicaFlag variable
- Simplify tests that had MySQL/PostgreSQL branches

* Update docs and test config to use PostgreSQL

- Update mmctl config set example to use postgres driver
- Update test-config.json to use PostgreSQL DSN format

* Remove MySQL migration scripts, test data, and docker image

Delete MySQL-related files that are no longer needed:
- ESR upgrade scripts (esr.*.mysql.*.sql)
- MySQL schema dumps (mattermost-mysql-*.sql)
- MySQL replication test scripts (replica-*.sh, mysql-migration-test.sh)
- MySQL test warmup data (mysql_migration_warmup.sql)
- MySQL docker image reference from mirror-docker-images.json

* Remove MySQL references from webapp

- Simplify minimumHashtagLength description to remove MySQL-specific configuration note
- Remove unused HIDE_MYSQL_STATS_NOTIFICATION preference constant
- Update en.json i18n source file

* clean up e2e-tests

* rm server/tests/template.load

* Use teamMemberSliceColumns() in UpdateMembersRole RETURNING clause

Refactor to use the existing helper function instead of hardcoding
the column names, ensuring consistency if the columns are updated.

* u.id -> u.Id

* address code review feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2026-01-20 21:01:59 +00:00
..
exif_samples
1x10000.png
1x10000_expected_preview.png
1x10000_expected_thumb.png
10000x1.png
10000x1_expected_preview.png
10000x1_expected_thumb.png
channel-role-has-permission.csv
crop_test_input.png
crop_test_output_45x45.png
crop_test_output_45x100.png
crop_test_output_100x45.png
crop_test_output_100x100.png
custom-schema-cpa.ldif
custom-schema-objectID.ldif
development-private-key.asc
development-public-key.asc
development-public-key.gpg
export_test.zip
Fake_Team_Import.rar
Fake_Team_Import.tar.gz
Fake_Team_Import.zip
fill_test_8bit_palette.png
fill_test_8bit_palette_out.png
fill_test_8bit_rgb.png
fill_test_8bit_rgb_out.png
fill_test_8bit_rgba.png
fill_test_8bit_rgba_out.png
fill_test_16bit_rgb.png
fill_test_16bit_rgb_out.png
fill_test_16bit_rgba.png
fill_test_16bit_rgba_out.png
fill_test_input.png
fill_test_opaque.png
fill_test_output_45x45.png
fill_test_output_45x100.png
fill_test_output_100x45.png
fill_test_output_100x100.png
fit_test_input.png
fit_test_output_45x45.png
fit_test_output_45x100.png
fit_test_output_100x45.png
fit_test_output_100x100.png
group-role-has-permission.csv
import_test.zip
large_image_file.jpg
large_lzw_frame.gif
orientation_test.jpeg
orientation_test_1.jpeg
orientation_test_1_expected_preview.jpeg
orientation_test_1_expected_thumb.jpeg
orientation_test_2.jpeg
orientation_test_2_expected_preview.jpeg
orientation_test_2_expected_thumb.jpeg
orientation_test_3.jpeg
orientation_test_3_expected_preview.jpeg
orientation_test_3_expected_thumb.jpeg
orientation_test_4.jpeg
orientation_test_4_expected_preview.jpeg
orientation_test_4_expected_thumb.jpeg
orientation_test_5.jpeg
orientation_test_5_expected_preview.jpeg
orientation_test_5_expected_thumb.jpeg
orientation_test_6.jpeg
orientation_test_6_expected_preview.jpeg
orientation_test_6_expected_thumb.jpeg
orientation_test_7.jpeg
orientation_test_7_expected_preview.jpeg
orientation_test_7_expected_thumb.jpeg
orientation_test_8.jpeg
orientation_test_8_expected_preview.jpeg
orientation_test_8_expected_thumb.jpeg
orientation_test_9.jpeg
orientation_test_9_expected_preview.jpeg
orientation_test_9_expected_thumb.jpeg
qa-data-graph.png
qa-data.ldif
README.md
sample-doc.doc
sample-doc.docx
sample-doc.odp
sample-doc.odt
sample-doc.pdf
sample-doc.pptx
sample-doc.rtf
slack-import-test-channels.json
slack-import-test-direct-messages.json
slack-import-test-group-direct-messages.json
slack-import-test-posts.json
slack-import-test-private-channels.json
slack-import-test-users.json
test-attachments.md
test-config.json Remove vestigial MySQL support (#34865) 2026-01-20 21:01:59 +00:00
test-data-graph.png
test-data.ldif
test-emoticons1.md
test-emoticons2.md
test-emoticons3.md
test-emoticons4.md
test-emoticons5.md
test-emoticons6.md
test-hashtags.md
test-link-preview.md
test-links.md
test-markdown-basics.md
test-markdown-lists.md
test-mentions.md
test-public-key.plugin.gpg
test-search.md
test-slack-attachments.json
test-syntax-highlighting.md
test-tables.md
test.png
test.svg
test.tiff
test_expected_tiff_preview.jpeg
test_expected_tiff_thumb.jpeg
test_img_diff_A.png
test_img_diff_B.png
testarchive.zip
testgif.gif
testgif_expected_preview.jpg
testgif_expected_thumbnail.jpg
testjpg.jpg
testplugin-v0.0.2.tar.gz
testplugin-v0.0.2.tar.gz.asc
testplugin-v0.0.2.tar.gz.sig
testplugin.tar.gz
testplugin.tar.gz.asc
testplugin.tar.gz.sig
testplugin2.tar.gz
testplugin2.tar.gz.asc
testplugin2.tar.gz.sig
testwebp.webp
tls_test_cert.pem
tls_test_key.pem

Testing Text Processing

The text processing tests located in the doc/developer/tests folder are designed for use with the /test url command. This command posts the raw contents of a specified .md file in the doc/developer/test folder into Mattermost.

Turning on /test

Access the System Console from the Main Menu. Under Service Settings make sure that Enable Testing is set to true, then click Save. You may also change this setting from config.json by setting ”EnableTesting”: true. Changing this setting requires a server restart to take effect.

Running the Tests

In the text input box in Mattermost, type: /test url [file-name-in-testing-folder].md. Some examples:

/test url test-emoticons.md
/test url test-links.md

Notes:

  1. If a test has prerequisites, make sure your Mattermost setup meets the requirements described at the top of the test file.
  2. Some tests are over 4000 characters in length and will render across multiple posts.

Manual Testing

It is possible to manually test specific sections of any test, instead of using the /test command. Do this by clicking Raw in the header for the file when its open in GitHub, then copy and paste any section into Mattermost to post it. Manual testing only supports sections of 4000 characters or less per post.

Test plugins

There are three test plugins: testplugin.tar.gz, testplugin-v0.0.2.tar.gz, and testplugin2.tar.gz. These are use in some integration tests in the api4 package. Any changes to the plugin bundles require updating the corresponding signatures.

First, import the public and private development key:

gpg --import ./development-public-key.gpg
gpg --import ./development-private-key.asc

This has to be done only once.

Then update the signatures:

gpg -u F3FACE45E0DE642C8BD6A8E64C7C6562C192CC1F --verbose --personal-digest-preferences SHA256 --detach-sign testplugin.tar.gz
gpg -u F3FACE45E0DE642C8BD6A8E64C7C6562C192CC1F --verbose --personal-digest-preferences SHA256 --detach-sign --armor testplugin.tar.gz
gpg -u F3FACE45E0DE642C8BD6A8E64C7C6562C192CC1F --verbose --personal-digest-preferences SHA256 --detach-sign testplugin-v0.0.2.tar.gz
gpg -u F3FACE45E0DE642C8BD6A8E64C7C6562C192CC1F --verbose --personal-digest-preferences SHA256 --detach-sign --armor testplugin-v0.0.2.tar.gz
gpg -u F3FACE45E0DE642C8BD6A8E64C7C6562C192CC1F --verbose --personal-digest-preferences SHA256 --detach-sign testplugin2.tar.gz
gpg -u F3FACE45E0DE642C8BD6A8E64C7C6562C192CC1F --verbose --personal-digest-preferences SHA256 --detach-sign --armor testplugin2.tar.gz

Finally, include the updates bundles and signatures in your commit.