Test and build performance improvements (#552)
* Small build perf improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove dead code. Stabilize test. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Further optimizations Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Upgrade mariadb driver. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raise timeouts for more robustness on slower build environments. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Move webappcontext into rest tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raised timeout. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove test dependency on target to groups distribution order. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code reuse. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Context available to tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Typos fixed. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix PollEvent send. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix typos. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Test log readability and removed unused method from CM. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove empty payload. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Stabilize tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Raised timeout. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed fire directory change during one test class run. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -10,23 +10,24 @@ package org.eclipse.hawkbit.rest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.rest.exception.ResponseExceptionHandler;
|
||||
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||
import org.eclipse.hawkbit.rest.util.HttpResponseFactoryBean;
|
||||
import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
/**
|
||||
* Configuration for Rest api.
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableHypermediaSupport(type = { HypermediaType.HAL })
|
||||
public class RestConfiguration {
|
||||
|
||||
@@ -34,7 +35,7 @@ public class RestConfiguration {
|
||||
* Create filter for {@link HttpServletResponse}.
|
||||
*/
|
||||
@Bean
|
||||
public FilterHttpResponse filterHttpResponse() {
|
||||
FilterHttpResponse filterHttpResponse() {
|
||||
return new FilterHttpResponse();
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ public class RestConfiguration {
|
||||
* Create factory bean for {@link HttpServletResponse}.
|
||||
*/
|
||||
@Bean
|
||||
public FactoryBean<HttpServletResponse> httpResponseFactoryBean() {
|
||||
FactoryBean<HttpServletResponse> httpResponseFactoryBean() {
|
||||
return new HttpResponseFactoryBean();
|
||||
}
|
||||
|
||||
@@ -51,7 +52,16 @@ public class RestConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_REQUEST)
|
||||
public RequestResponseContextHolder requestResponseContextHolder() {
|
||||
RequestResponseContextHolder requestResponseContextHolder() {
|
||||
return new RequestResponseContextHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ControllerAdvice} for mapping {@link RuntimeException}s from the
|
||||
* repository to {@link HttpStatus} codes.
|
||||
*/
|
||||
@Bean
|
||||
ResponseExceptionHandler responseExceptionHandler() {
|
||||
return new ResponseExceptionHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,22 +11,47 @@ package org.eclipse.hawkbit.rest;
|
||||
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||
import org.eclipse.hawkbit.security.ExcludePathAwareShallowETagFilter;
|
||||
import org.junit.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
/**
|
||||
* Abstract Test for Rest tests.
|
||||
*/
|
||||
@WebAppConfiguration
|
||||
@SpringApplicationConfiguration(classes = { RestConfiguration.class, RepositoryApplicationConfiguration.class })
|
||||
public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTest {
|
||||
|
||||
protected MockMvc mvc;
|
||||
|
||||
@Autowired
|
||||
private FilterHttpResponse filterHttpResponse;
|
||||
|
||||
@Autowired
|
||||
protected WebApplicationContext webApplicationContext;
|
||||
|
||||
@Override
|
||||
protected DefaultMockMvcBuilder createMvcWebAppContext() {
|
||||
final DefaultMockMvcBuilder createMvcWebAppContext = super.createMvcWebAppContext();
|
||||
return createMvcWebAppContext.addFilter(filterHttpResponse);
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
mvc = createMvcWebAppContext(webApplicationContext).build();
|
||||
}
|
||||
|
||||
protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) {
|
||||
final DefaultMockMvcBuilder createMvcWebAppContext = MockMvcBuilders.webAppContextSetup(context);
|
||||
|
||||
createMvcWebAppContext.addFilter(
|
||||
new ExcludePathAwareShallowETagFilter("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download",
|
||||
"/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/**",
|
||||
"/api/v1/downloadserver/**"));
|
||||
createMvcWebAppContext.addFilter(filterHttpResponse);
|
||||
|
||||
return createMvcWebAppContext;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user