Skip to content

Commit

Permalink
feat(case limit): make Community limited (#3124)
Browse files Browse the repository at this point in the history
* feat(case limit): limit case start / period of time
* feat(case limit): warn admin when reaching 80%, 90%
* feat(case limit): read counters at startup instead of at first process start. This allows to fail fast if DB has been modified!

relates to https://bonitasoft.atlassian.net/browse/BPM-242

relates to https://bonitasoft.atlassian.net/browse/BPM-238
  • Loading branch information
educhastenier authored Sep 6, 2024
1 parent f0f0522 commit 88ea2c9
Show file tree
Hide file tree
Showing 31 changed files with 815 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void initializeJNDI() throws NamingException {

public void start() throws Exception {
initializeEnvironment();
PlatformSetup platformSetup = PlatformSetupAccessor.getPlatformSetup();
PlatformSetup platformSetup = getPlatformSetup();
platformSetup.init();

PlatformSession platformSession = loginOnPlatform();
Expand All @@ -126,6 +126,10 @@ public void start() throws Exception {
logoutFromPlatform(platformSession);
}

protected PlatformSetup getPlatformSetup() throws NamingException {
return PlatformSetupAccessor.getInstance().getPlatformSetup();
}

private void logoutFromPlatform(PlatformSession platformSession)
throws PlatformLogoutException, SessionNotFoundException, BonitaHomeNotSetException, ServerAPIException,
UnknownAPITypeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ public void clean() throws Exception {
}
};

/**
* @return warning list of unclean elements
* @throws BonitaException
*/
private void clean() throws BonitaException {
loginOnDefaultTenantWithDefaultTechnicalUser();
cleanCommands();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<logger name="org.bonitasoft" level="INFO" />
<logger name="org.hibernate.orm.cache" level="WARN" />
<logger name="org.hibernate.SQL_SLOW" level="INFO"/>
<logger name="org.bonitasoft.engine.execution.ProcessStarterVerifierImpl" level="DEBUG"/>

<root level="INFO">
<appender-ref ref="STDOUT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertEquals;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -147,13 +145,12 @@ private List<SJobDescriptor> searchJobDescriptors(final int nbOfExpectedJobDescr
public void retryAJob_should_update_job_log_when_execution_fails_again() throws Exception {
//given
getCommandAPI().register("except", "Throws Exception when scheduling a job", AddJobCommand.class.getName());
final Map<String, Serializable> parameters = new HashMap<>();
try {
getCommandAPI().execute("except", parameters);
getCommandAPI().execute("except", Map.of());
FailedJob failedJob = await().until(() -> getProcessAPI().getFailedJobs(0, 100), hasSize(1)).get(0);

//when
getProcessAPI().replayFailedJob(failedJob.getJobDescriptorId(), emptyMap());
getProcessAPI().replayFailedJob(failedJob.getJobDescriptorId());

//then
failedJob = await().until(() -> getProcessAPI().getFailedJobs(0, 100), hasSize(1)).get(0);
Expand Down
3 changes: 3 additions & 0 deletions bonita-integration-tests/bonita-test-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ dependencies {
api libs.commonsIO
api "xmlunit:xmlunit:${Deps.xmlunitVersion}"
api "org.assertj:assertj-core:${Deps.assertjVersion}"

implementation project(':bpm:bonita-core:bonita-process-engine')
implementation libs.springTest
}

publishing {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@
import org.bonitasoft.engine.exception.BonitaHomeNotSetException;
import org.bonitasoft.engine.exception.ServerAPIException;
import org.bonitasoft.engine.exception.UnknownAPITypeException;
import org.bonitasoft.engine.execution.ProcessStarterVerifier;
import org.bonitasoft.engine.session.PlatformSession;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;

/**
* @author Celine Souchet
*/
@ContextConfiguration(classes = PlatformTestUtil.TestConfiguration.class)
public class PlatformTestUtil {

public static final String DEFAULT_TECHNICAL_LOGGER_USERNAME = "install";
Expand Down Expand Up @@ -72,4 +77,17 @@ public void deployCommandsOnDefaultTenant() throws BonitaException {
apiClient.logout();
}

/**
* Configuration class used to override bean definitions for test purposes.
*/
@Configuration
static class TestConfiguration {

@Bean
ProcessStarterVerifier processStarterVerifierImpl() {
return processInstance -> {
// Override this bean to disable the process starter verifier
};
}
}
}
2 changes: 2 additions & 0 deletions bonita-test-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ dependencies {
api "junit:junit:${Deps.junit4Version}"
api(project(':platform:platform-resources'))

implementation libs.springTest

// for http tests:
compileOnly("org.eclipse.jetty:jetty-server:${Deps.jettyVersion}")
compileOnly("org.eclipse.jetty:jetty-servlet:${Deps.jettyVersion}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.bonitasoft.engine.BonitaDatabaseConfiguration;
import org.bonitasoft.engine.execution.ProcessStarterVerifier;
import org.bonitasoft.engine.test.http.BonitaHttpServer;
import org.bonitasoft.engine.test.internal.EngineCommander;
import org.bonitasoft.engine.test.internal.EngineStarter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;

/**
* @author Baptiste Mesta
*/
@Getter
@Slf4j
@ContextConfiguration(classes = TestEngineImpl.TestConfiguration.class)
public class TestEngineImpl implements TestEngine {

private static TestEngineImpl INSTANCE = createTestEngine();
Expand Down Expand Up @@ -129,4 +134,17 @@ public void setBusinessDataDatabaseProperties(BonitaDatabaseConfiguration databa
this.businessDataDatabaseConfiguration = database;
}

/**
* Configuration class used to override bean definitions for test purposes.
*/
@Configuration
static class TestConfiguration {

@Bean
ProcessStarterVerifier processStarterVerifierImpl() {
return processInstance -> {
// Override this bean to disable the process starter verifier
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.nio.file.Path;
import java.util.*;

import javax.naming.NamingException;

import org.apache.commons.io.FileUtils;
import org.bonitasoft.engine.BonitaDatabaseConfiguration;
import org.bonitasoft.engine.BonitaEngine;
Expand Down Expand Up @@ -56,7 +58,7 @@ public class EngineStarter {
private static boolean hasFailed = false;

private boolean dropOnStart = true;
private BonitaEngine engine;
private final BonitaEngine engine;

protected EngineStarter(BonitaEngine engine) {
this.engine = engine;
Expand All @@ -76,7 +78,7 @@ public void start() throws Exception {
}
try {
LOGGER.info("=====================================================");
LOGGER.info("============ Starting Bonita Engine ===========");
LOGGER.info("============== Starting Bonita Engine =============");
LOGGER.info("=====================================================");
final long startTime = System.currentTimeMillis();
System.setProperty("com.arjuna.ats.arjuna.common.propertiesFile", "jbossts-properties.xml");
Expand All @@ -102,12 +104,16 @@ public void start() throws Exception {
}

protected void setupPlatform() throws Exception {
PlatformSetup platformSetup = PlatformSetupAccessor.getPlatformSetup();
PlatformSetup platformSetup = getPlatformSetup();
if (isDropOnStart()) {
platformSetup.destroy();
}
}

protected PlatformSetup getPlatformSetup() throws NamingException {
return PlatformSetupAccessor.getInstance().getPlatformSetup();
}

//-------------- engine life cycle methods

protected void prepareEnvironment() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
**/
package org.bonitasoft.engine.api.internal.servlet;

import javax.naming.NamingException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.bonitasoft.engine.EngineInitializer;
import org.bonitasoft.engine.service.impl.ServiceAccessorFactory;
import org.bonitasoft.platform.setup.PlatformSetup;
import org.bonitasoft.platform.setup.PlatformSetupAccessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -56,7 +58,7 @@ public void contextInitialized(final ServletContextEvent event) {

AnnotationConfigWebApplicationContext initializeWebApplicationContext(ServletContextEvent event,
EngineInitializer engineInitializer) throws Exception {
PlatformSetupAccessor.getPlatformSetup().init(); // init tables and default configuration
getPlatformSetup().init(); // init tables and default configuration
engineInitializer.initializeEngine();
ApplicationContext engineContext = ServiceAccessorFactory.getInstance()
.createServiceAccessor()
Expand All @@ -67,6 +69,10 @@ AnnotationConfigWebApplicationContext initializeWebApplicationContext(ServletCon
return webApplicationContext;
}

protected PlatformSetup getPlatformSetup() throws NamingException {
return PlatformSetupAccessor.getInstance().getPlatformSetup();
}

void exit(int code) {
System.exit(code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ default Application getApplication(final long applicationId) throws ApplicationN
} else {
throw new ApplicationNotFoundException(applicationId);
}
};
}

/**
* Retrieves an {@link IApplication} from its identifier.
Expand Down
Loading

0 comments on commit 88ea2c9

Please sign in to comment.