shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Postgresql data-pipeline tests fails to run on Windows machine

Open TedCraft opened this issue 2 years ago • 2 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

Latest.

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

Expected behavior

Tests passed, build completed successfully.

Actual behavior

PostgreSQLTablePropertiesLoaderTest.assertLoad(), PostgreSQLPipelineFreemarkerManagerTest.assertGetSQLByDefaultVersion() and PostgreSQLIndexSQLGeneratorTest.assertGenerate() tests fails.

Reason analyze (If you can)

Tests fails because of using System.lineSeparator() in mocking and asserting SQL strings. Windows uses \r\n as a line separator, when Linux uses \n and corresponding .ftl files also uses \n.

For exmaple, in PostgreSQLIndexGeneratorTest executeQuery function is mocked. When it contains string "SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name," + System.lineSeparator() + "(SELECT (CASE WHEN count(i.inhrelid) > 0 THEN true ELSE false END)" it should return getNodesResultSet. In Linux systems this string is looking exactly as corresponding string in nodes.ftl file, but on Windows behaviour of System.lineSeparator() is different and as a result executeQuery returns null.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Run postgresql data-pipeline tests on Windows machine.

Example codes for reproduce this issue (such as a github link).

TedCraft avatar Nov 24 '24 23:11 TedCraft

Hello, I reviewed the bug report and identified that using System.lineSeparator() on Windows adds \r\n line endings, which do not match the \n line endings used in the text files configured in the repository. This mismatch causes test failures on Windows systems.

To address this, I propose replacing System.lineSeparator() with "\n" to ensure consistency across platforms. Since .ftl and other text files in the repository use \n as the standard line separator, this change will ensure tests behave consistently regardless of the operating system.

I have some changes ready. Could you please assign this issue to me?

omkar-shitole avatar Dec 06 '24 10:12 omkar-shitole

@omkar-shitole Great, please go ahead!

terrymanu avatar Dec 06 '24 10:12 terrymanu