I have a Modular Monothic Application in which I have around 10 Modules. I Have written ArchTest Cases in one of the module which freezes all the existing violations(across all the existing modules) in a file.(Executed in my local by having all the 10 modules in my intellj)

Now When I am executing that test case in Jenkins by checking out only one module.(We are building parallely all the modules in jenkins).It is giving me the below error

com.tngtech.archunit.library.freeze.StoreUpdateFailedException: Updating frozen violations is disabled (enable by configuration freeze.store.default.allowStoreUpdate=true)

In ArchUnit Tests, If violations are fixed, FreezingArchRule will automatically reduce the known stored violations to prevent any regression.Is there any way to stop this behaviour?

1

There are 1 best solutions below

0
Manfred On

Did I understand correctly that the ArchTest gives fewer violations when building a single module and therefore wants to reduce the violation store, which you don't allow on your Jenkins?

Couldn't you just adapt the freeze.store.default.allowStoreUpdate property to allow store updates? That would be the most pragmatic workaround (assuming that Jenkins has write access to these files).

But I would actually recommend using individual violation store files (via an appropriate freeze.store.default.path configuration, e.g. pointing to a relative path in each module) to avoid any coupling between modules which may or may not be checked out.

To answer your question whether it is possible to stop FreezingArchRule to automatically reduce the known stored violations: Technically, you could use a custom Violation Store that just does not save violations such as

class NonSavingTextFileBasedViolationStore implements ViolationStore {

    private final ViolationStore delegate = new TextFileBasedViolationStore();

    @Override
    public void initialize(Properties properties) {
        delegate.initialize(properties);
    }

    @Override
    public boolean contains(ArchRule rule) {
        return delegate.contains(rule);
    }

    @Override
    public void save(ArchRule rule, List<String> violations) {
        // do not save
    }

    @Override
    public List<String> getViolations(ArchRule rule) {
        return delegate.getViolations(rule);
    }
}

See the Violation Store documentation how to configure FreezingArchRule to use it.