Skip to content

Commit

Permalink
Merge pull request #308 from Cognifide/update-osgi-annotations-test-e…
Browse files Browse the repository at this point in the history
…xecutor

Update annotations in test executor
  • Loading branch information
plutasnyy authored Aug 9, 2018
2 parents bfebd04 + 375fda5 commit 48c7ea2
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 69 deletions.
20 changes: 19 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,24 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
<version>1.3.0</version>
<scope>provided</scope>
</dependency>

<!-- Tests -->
<dependency>
Expand Down Expand Up @@ -701,7 +719,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.1.1168</version>
<version>3.4.1.1168</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
24 changes: 10 additions & 14 deletions test-executor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,16 @@
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>

<dependency>
Expand All @@ -123,18 +131,6 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.cognifide.aet.communication.api.metadata.Suite;
import com.cognifide.aet.communication.api.metadata.ValidatorException;
import com.cognifide.aet.communication.api.queues.JmsConnection;
import com.cognifide.aet.executor.configuration.SuiteExecutorConf;
import com.cognifide.aet.executor.http.HttpSuiteExecutionResultWrapper;
import com.cognifide.aet.executor.model.TestRun;
import com.cognifide.aet.executor.model.TestSuiteRun;
Expand All @@ -29,7 +30,6 @@
import com.cognifide.aet.executor.xmlparser.xml.XmlTestSuiteParser;
import com.cognifide.aet.rest.LockService;
import com.cognifide.aet.rest.helpers.ReportConfigurationManager;
import com.cognifide.aet.vs.MetadataDAO;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalListener;
Expand All @@ -44,13 +44,12 @@
import javax.jms.JMSException;
import javax.jms.Session;
import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.http.HttpStatus;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.Designate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -59,9 +58,8 @@
* It creates the {@link SuiteRunner} and {@link SuiteStatusResult} queue for each test suite run
* and keeps those items in cache.
*/
@Service(SuiteExecutor.class)
@Component(label = "AET Suite Executor", description = "Executes received test suite", immediate = true,
metatype = true)
@Component(service = SuiteExecutor.class, immediate = true)
@Designate(ocd = SuiteExecutorConf.class)
public class SuiteExecutor {

private static final Logger LOGGER = LoggerFactory.getLogger(SuiteExecutor.class);
Expand All @@ -72,17 +70,11 @@ public class SuiteExecutor {

private static final String XUNIT_REPORT_URL_FORMAT = "%s/xunit?company=%s&project=%s&correlationId=%s";

private static final String MESSAGE_RECEIVE_TIMEOUT_PROPERTY_NAME = "messageReceiveTimeout";

private static final String LOCKED_SUITE_MESSAGE = "Suite is currently locked. Please try again later.";

private static final long CACHE_EXPIRATION_TIMEOUT = 20000L;

private static final long DEFAULT_MESSAGE_RECEIVE_TIMEOUT = 300000L;

@Property(name = MESSAGE_RECEIVE_TIMEOUT_PROPERTY_NAME, label = "ActiveMQ message receive timeout",
description = "ActiveMQ message receive timeout", longValue = DEFAULT_MESSAGE_RECEIVE_TIMEOUT)
private Long messageReceiveTimeout;
private SuiteExecutorConf config;

@Reference
private JmsConnection jmsConnection;
Expand All @@ -108,9 +100,8 @@ public class SuiteExecutor {
private SuiteStatusHandler suiteStatusHandler;

@Activate
public void activate(Map<String, Object> properties) {
messageReceiveTimeout = PropertiesUtil.toLong(
properties.get(MESSAGE_RECEIVE_TIMEOUT_PROPERTY_NAME), DEFAULT_MESSAGE_RECEIVE_TIMEOUT);
public void activate(SuiteExecutorConf config) {
this.config = config;

suiteRunnerCache = CacheBuilder.newBuilder()
.expireAfterAccess(CACHE_EXPIRATION_TIMEOUT, TimeUnit.MILLISECONDS)
Expand Down Expand Up @@ -235,7 +226,7 @@ private boolean lockTestSuite(Suite suite) {
private SuiteRunner createSuiteRunner(Suite suite) throws JMSException {
Session session = jmsConnection.getJmsSession();
SuiteRunner suiteRunner = new SuiteRunner(session, cacheUpdater,
suiteStatusHandler, suite, RUNNER_IN_QUEUE, messageReceiveTimeout);
suiteStatusHandler, suite, RUNNER_IN_QUEUE, config.messageReceiveTimeout());
suiteRunnerCache.put(suite.getCorrelationId(), suiteRunner);
suiteStatusCache.put(suite.getCorrelationId(), new ConcurrentLinkedQueue<SuiteStatusResult>());
return suiteRunner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,12 @@
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Service(SuiteFactory.class)
@Component(
label = "AET Suite Factory",
description = "Creates a new Suite object from the test suite",
immediate = true
)
@Component(service = SuiteFactory.class, immediate = true)
public class SuiteFactory {

private static final Logger LOG = LoggerFactory.getLogger(SuiteFactory.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,17 @@
import org.apache.commons.fileupload.util.Streams;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.http.HttpStatus;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service
@Component(label = "SuiteServlet", description = "Executes received test suite", immediate = true)
@Component(service = HttpServlet.class, immediate = true)
public class SuiteServlet extends HttpServlet {

private static final long serialVersionUID = 5266041156537459410L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service
@Component(label = "SuiteStatusServlet", description = "Returns status of test suite processing",
immediate = true)
@Component(service = HttpServlet.class, immediate = true)
public class SuiteStatusServlet extends HttpServlet {

private static final Logger LOGGER = LoggerFactory.getLogger(SuiteStatusServlet.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@
import com.google.common.base.Joiner;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service(SuiteValidator.class)
@Component(
label = "AET Suite Validator",
description = "Validates received test suite",
immediate = true
)
@Component(service = SuiteValidator.class, immediate = true)
public class SuiteValidator {

private static final Logger LOG = LoggerFactory.getLogger(SuiteValidator.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* AET
*
* Copyright (C) 2013 Cognifide Limited
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.cognifide.aet.executor.configuration;

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "AET Suite Executor Configuration" , description = "Executes received test suite")
public @interface SuiteExecutorConf {

String MESSAGE_RECEIVE_TIMEOUT_PROPERTY_NAME = "messageReceiveTimeout";

long DEFAULT_MESSAGE_RECEIVE_TIMEOUT = 300000L;

@AttributeDefinition(name = MESSAGE_RECEIVE_TIMEOUT_PROPERTY_NAME, description = "ActiveMQ message receive timeout", type = AttributeType.LONG)
long messageReceiveTimeout() default DEFAULT_MESSAGE_RECEIVE_TIMEOUT;

}

0 comments on commit 48c7ea2

Please sign in to comment.