Skip to content

test: add regression tests for FileConfiguration#8151

Open
amirdeljouyi wants to merge 1 commit into
apache:2.xfrom
amirdeljouyi:test-add-regression-tests-for-fileconfiguration
Open

test: add regression tests for FileConfiguration#8151
amirdeljouyi wants to merge 1 commit into
apache:2.xfrom
amirdeljouyi:test-add-regression-tests-for-fileconfiguration

Conversation

@amirdeljouyi

Copy link
Copy Markdown

test: add regression tests for FileConfiguration

Ⅰ. Describe what this PR did

I added three regression tests for the file-backed configuration API.

The tests cover reads, default-value behavior for missing keys, and mutation operation outcomes.

Impact on coverage:

The tests cover the main file-backed read and mutation paths in FileConfiguration, plus timeout handling in the config operation runnable. In the focused JaCoCo
run, FileConfiguration.java branch coverage increases around 3%.

Ⅱ. Does this pull request fix one issue?

No linked issue; this is a test-only regression-coverage change.

Ⅲ. Why don't you add test cases (unit test/integration test)?

This PR consists entirely of unit tests.

Ⅳ. Describe how to verify it

Run ./mvnw -pl config/seata-config-core -am -Dtest=FileConfigurationTest -DfailIfNoTests=false test.

Ⅴ. Special notes for reviews

No production code or API behavior is changed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional unit test coverage around the file-backed Configuration implementation accessed via ConfigurationFactory, aiming to prevent regressions in read/default/mutation paths.

Changes:

  • Adds three new regression tests validating file-backed reads, default behavior for missing keys, and mutation outcomes through ConfigurationFactory.
  • Refactors existing assertions to use static assertTrue/assertFalse imports.
  • Updates many test methods to declare throws Exception.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Configuration fileConfig = ConfigurationFactory.getInstance();
boolean value = fileConfig.getBoolean("test.boolean.key", true, 1000);
Assertions.assertTrue(value || !value);
assertTrue(value || !value);
Configuration fileConfig = ConfigurationFactory.getInstance();
boolean result = fileConfig.putConfig("test.put.key", "test-value");
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
Configuration fileConfig = ConfigurationFactory.getInstance();
boolean result = fileConfig.putConfig("test.put.key", "test-value", 1000);
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
Configuration fileConfig = ConfigurationFactory.getInstance();
boolean result = fileConfig.putConfigIfAbsent("test.absent.key", "test-value");
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
Configuration fileConfig = ConfigurationFactory.getInstance();
boolean result = fileConfig.putConfigIfAbsent("test.absent.key", "test-value", 1000);
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
fileConfig.putConfig("test.remove.key", "test-value");
boolean result = fileConfig.removeConfig("test.remove.key", 1000);
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
Comment on lines +478 to +484
@Test
void shouldDelegateFileBackedReadsThroughConfigurationFactory() {
Configuration fileConfig = ConfigurationFactory.getInstance();

Assertions.assertEquals("127.0.0.1:8091", fileConfig.getConfig("service.default.grouplist"));
assertFalse(fileConfig.getBoolean("service.disableGlobalTransaction"));
}
Configuration fileConfig = ConfigurationFactory.getInstance();
boolean putResult = fileConfig.putConfig("test.put.get", "put-value");
Assertions.assertTrue(putResult || !putResult);
assertTrue(putResult || !putResult);
System.setProperty("test.put.if.absent", "existing-value");
boolean result = fileConfig.putConfigIfAbsent("test.put.if.absent", "new-value");
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
System.setProperty("test.remove.existing", "value");
boolean result = fileConfig.removeConfig("test.remove.existing");
Assertions.assertTrue(result || !result);
assertTrue(result || !result);
@WangzJi WangzJi added the type: test test case label Jul 10, 2026
@amirdeljouyi amirdeljouyi force-pushed the test-add-regression-tests-for-fileconfiguration branch from b27a25b to c06688b Compare July 12, 2026 13:43
@WangzJi WangzJi requested a review from Copilot July 13, 2026 02:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +477 to +493
String dataId = "service.disableGlobalTransaction";
String previousValue = System.getProperty(dataId);
try {
System.clearProperty(dataId);
ConfigurationFactory.reload();
Configuration fileConfig = ConfigurationFactory.getInstance();

Assertions.assertEquals("127.0.0.1:8091", fileConfig.getConfig("service.default.grouplist"));
Assertions.assertFalse(fileConfig.getBoolean(dataId));
} finally {
if (previousValue == null) {
System.clearProperty(dataId);
} else {
System.setProperty(dataId, previousValue);
}
ConfigurationFactory.reload();
}
Comment on lines +510 to +512
Assertions.assertTrue(fileConfig.putConfig("adopted.put.key", "value", 1000L));
Assertions.assertTrue(fileConfig.putConfigIfAbsent("adopted.put-if-absent.key", "value", 1000L));
Assertions.assertTrue(fileConfig.removeConfig("adopted.remove.key", 1000L));
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.81%. Comparing base (b57d96c) to head (c06688b).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #8151      +/-   ##
============================================
+ Coverage     72.79%   72.81%   +0.01%     
  Complexity     1141     1141              
============================================
  Files          1151     1151              
  Lines         42272    42272              
  Branches       5045     5045              
============================================
+ Hits          30773    30780       +7     
+ Misses         9023     9019       -4     
+ Partials       2476     2473       -3     

see 4 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: test test case

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants