Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/rewrite reddeer test suite run with requirements loaded from config file #1586

Merged
merged 1 commit into from
Mar 16, 2017

Conversation

odockal
Copy link
Member

@odockal odockal commented Feb 13, 2017

Aim is to be able to run multiple test runs on single test suite based on annotated requirements loaded from single config file. This is especially aiming to use of JRE and Server (only to those?) requirements together defined with one single config xml file. Such loaded requirement configuration would create matrix of combination of possible configurations that would test suite be run with.

@rawagner
Copy link
Member

not just JRE/Server, those were just examples. This have to work with any other.

@odockal
Copy link
Member Author

odockal commented Jan 23, 2017

Expected output:
Once config.xml is loaded, it could has multiple requirement elements that contains JRE and/or Server specific definition. Based on used annotation/requirements that main suite runs with, and based on parameters used on these requirements, test run configuration would take into account all allowed combinations of requirements set up and run test with each such req. configuration.
Examples of annotation usage:

  • @jre(version="1.6") -> 1 test run
  • @jre() -> based on how many JRE are defined in config xml file, runs all of them, (or none)
    this might be restricted with a param, vesion="ANY" would run all defined JRE otherwise none would be run
  • @jre(version="1.6", compare="GREATER_THAN") - would run any JRE that fulfills condition such as, search for: JRE is GREATER_THAN (compare param value) 1.6 (version value), default is EQUALS condition.
  • @server (state=..., type=EAP, version=7.0) -> 1 test run
  • @server (type=AS, version=7.1, compare=LESS_THAN) -> would run x times where x is the number of defined AS servers under verion 7.1 that occured in config.xml
  • @server () -> would runamount of the tests with respect to number of defined server runtimes
  • @jre (conditions) and @server (conditions) -> would run x tests by number of applicable JRE times number of server runtimes

Please, edit this document if necessary.

@odockal
Copy link
Member Author

odockal commented Jan 23, 2017

@rawagner @mlabuda @apodhrad @rhopp @psrna I think that this will be quite more complex, than one could expect. Express any ideas, please.

@rawagner
Copy link
Member

looks good! Another possibility could be to specifically define all versions required for example @jre(version="1,6","1.8") (1.7 is missing).

@mlabuda
Copy link
Member

mlabuda commented Jan 23, 2017

Two ideas:

  • @SomeRequirement() would run all suitable requirements. I would be carefull with ANY and running all of them, because one could expect by providing "ANY" to run any - one and only one. So using ANY for version would trigger only one test run for a first found config.
  • I would try to do something like @jre(@Version(min="1.7")) to run a test with all JREs higher or equal to JRE 1.7. Then another @jre(@Version(exclude="1.7")) to run all with all specified JRE's expect 1.7. Or @jre(@Version(min="1.6", exclude="1.9")) to run with with all JREs higher than 1.6 but exclude 1.9 from the test run. Default usage would be @jre(@Version("1.6")) which would run a test only with JRE 1.6. Other comparison operators could be "max"...

@rhopp
Copy link
Contributor

rhopp commented Jan 23, 2017

Guys... keep in mind that we are trying to design something more general. We used server/jre as an example. Another example could be databases and connections. One could have configuration file with X URL's to different databases (and for example even with different credentials) and we should be able to provide "something" in this core implementation which would enable user to create it's own restrictions of which configurations should be running and which not.

@rhopp
Copy link
Contributor

rhopp commented Jan 23, 2017

In other words: I think that "restriction management" should be done on requiement level (every requirement should be able to decide by itself). But the core implementation (this issue) must provide everything the requiement could need to make that decision.

@mlabuda
Copy link
Member

mlabuda commented Jan 23, 2017

If restriction management will be done on requirement level - requirement should decide on itself whether to run or not, we would already get error/failures in execution, because requirement would fail on fulfill/canFulfill. We should address requirements to run as well, e.g. in requirement builder.

But to the point, @SomeReq() should run all defined reqs in xml. @SomeReq() @SomeReq2() should run defined reqs combination (MxN). Restrictions would limit amount of requirements to run tests with, combinations with other requirements should be preserved.

@odockal
Copy link
Member Author

odockal commented Feb 13, 2017

DO NOT MERGE!
This is first prove of concept commit. Its purpose is to try run multiple tests with more than one configuration used in config.xml file. Not ready yet for PR review, though.
@rawagner, @mlabuda, @rhopp, @jrichter1, @jkopriva, @theJNOVAK, @psrna: Feel free to comment, edit, test, whatever...
You can use org.jboss.reddeer.requirements.test.multipleconfigs package to test new features.
TODO:

  • Cover test class that is run as a suite class and does not contains other classes
  • Add support for nested suites
  • Remove classes used to run test in old way
  • Rename new classes, add comments, use proper naming convention
  • Refactor inner structure (data structures and code used)
  • Include PropertyBasedConfiguration
  • Use NullTestRunConfiguration
  • Rewrite tests
  • Define changes to existing API
  • Change design of run test class configuration
  • Improve/Test Performance
  • Only one config file on given path

@odockal odockal force-pushed the reddeerReqConfig branch 4 times, most recently from 4183081 to 3bcdec9 Compare February 14, 2017 07:58
@rawagner
Copy link
Member

We want to support only one config file which means that SuiteConfiguration.getListOfConfigurationsPerFile() should be renamed and should return just one file

@rawagner
Copy link
Member

check support for nested suites

@rawagner
Copy link
Member

require requirements .xml file not just folder

@mlabuda
Copy link
Member

mlabuda commented Feb 14, 2017

Could you please create more lightweight tests? Using server requirement and JRE requirement seems too much for me. Create 2 simple requirements (or if there are existing for testing, use those) and assert numbers of executed classes/tests for various combination are equal to expected numbers..

@odockal odockal force-pushed the reddeerReqConfig branch 3 times, most recently from 2a6b1c0 to edc381c Compare February 15, 2017 23:23
@odockal
Copy link
Member Author

odockal commented Feb 16, 2017

testPR

@odockal odockal force-pushed the reddeerReqConfig branch 5 times, most recently from 9ecdfa1 to 0da34d8 Compare February 23, 2017 16:01
@odockal odockal force-pushed the reddeerReqConfig branch 3 times, most recently from a55e021 to 2d2dead Compare March 9, 2017 09:00
@odockal
Copy link
Member Author

odockal commented Mar 9, 2017

@rawagner @mlabuda @apodhrad @rhopp @jkopriva @jrichter1 @theJNOVAK
Take a look, amigos. Builds'n'tests seems be almost stable (in case of tests), PR still requires some work but I suggest to do it in the form of another commit/fixup.

* @author odockal
*
*/
public class RequirementConfigurationObject {
Copy link
Member

Choose a reason for hiding this comment

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

rename to RequirementConfiguration

@@ -31,7 +32,7 @@
* @author Lucia Jelinkova
* @see TestRunConfiguration
*/
public class RequirementsConfigurationImpl implements RequirementsConfiguration{
Copy link
Member

@rawagner rawagner Mar 9, 2017

Choose a reason for hiding this comment

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

rename to RequirementsConfiguratorImpl and interface to RequirementsConfigurator

Copy link
Member Author

Choose a reason for hiding this comment

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

I left this classes intact, we agreed on that, right?

* Gets all test classes as an array.
* @return all test classes as an array
*/
public Class<?>[] getClassesAsArray() {
Copy link
Member

Choose a reason for hiding this comment

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

one liner testClasses.toArray(new Class<?>[testClasses.size()]);

Requirement<Annotation> requirement = (Requirement<Annotation>) createInstance(this.requirementConfigurationClass.getEnclosingClass());

if (!(requirement instanceof CustomConfiguration || requirement instanceof PropertyConfiguration)){
throw new IllegalArgumentException("The requirement does not implement " + CustomConfiguration.class);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldnt you mention PropertyConfiguration.class too ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mentioned.

if (configs.isEmpty()){
throw new RedDeerConfigurationException("No configuration found in XML configuration file for requirement class " + customConfiguration.getClass());
// iterate over all configurations and tries to cast the configuration object to expected configuration class
// Class cast exception is caught and iteration continues, if none configuration fits, new
Copy link
Member

Choose a reason for hiding this comment

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

"new" what ? Something is missing in the comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment deleted, Method's javadoc description updated.

// Class cast exception is caught and iteration continues, if none configuration fits, new
boolean configurationSet = false;
for (Object configuration : this.configurations) {
try {
Copy link
Member

Choose a reason for hiding this comment

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

change try-catch to isAssignableFrom


boolean configurationSet = false;
for (Object configuration : this.configurations) {
try {
Copy link
Member

Choose a reason for hiding this comment

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

change try-catch to isAssignableFrom

Copy link
Member Author

Choose a reason for hiding this comment

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

One catch removed - added if with PropertyBasedConfiguration.class.isAssignableFrom(configuration.getClass()) condition.

@@ -51,6 +51,7 @@ public int compare(Class<?> clazz0, Class<?> clazz1) {
* as test class without a run
*/
public void addTest(Class<?> testClass) {
System.out.println("Adding class without a run: " + testClass.getName());
Copy link
Member

Choose a reason for hiding this comment

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

use logger

Copy link
Member Author

Choose a reason for hiding this comment

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

println deleted

@@ -62,6 +63,7 @@ public void addTest(Class<?> testClass) {
* as test class with a run
*/
public void addExecutedTest(Class<?> testClass) {
System.out.println("Adding class with a run: " + testClass.getName());
Copy link
Member

Choose a reason for hiding this comment

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

logger

Copy link
Member Author

Choose a reason for hiding this comment

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

no need for output.

@@ -5,7 +5,7 @@

<!-- Import basic RedDeer requirements -->
<xs:import namespace="http://www.jboss.org/NS/Req"
schemaLocation="http://www.jboss.org/schema/reddeer/v1/RedDeerSchema.xsd" />
schemaLocation="RedDeerSchema2.xsd" />
Copy link
Member

Choose a reason for hiding this comment

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

undo the change

Copy link
Member Author

Choose a reason for hiding this comment

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

undone.

@@ -85,6 +86,12 @@ public boolean canFulfill() {
}
}

@Override
public boolean isDeclarationAcceptable() {
// TODO Delete random generating
Copy link
Member

Choose a reason for hiding this comment

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

remove TODO

Copy link
Member Author

Choose a reason for hiding this comment

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

I deleted whole method. It is declared with default value in the interface.

rawagner added a commit to rawagner/reddeer that referenced this pull request Mar 10, 2017
int i = 0;
while (realSequenceIterator.hasNext() && expectedSequenceIterator.hasNext()){
Object real = realSequenceIterator.next();
Object expected = expectedSequenceIterator.next();
System.out.println(real.toString() + " vs. " + expected.toString());
Copy link
Member

Choose a reason for hiding this comment

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

log

Copy link
Member Author

Choose a reason for hiding this comment

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

no need for output...

odockal pushed a commit to odockal/reddeer that referenced this pull request Mar 13, 2017
@odockal
Copy link
Member Author

odockal commented Mar 13, 2017

I need to update some unit tests for CustomConfigurator.

@odockal odockal force-pushed the reddeerReqConfig branch 3 times, most recently from f341215 to 73220c5 Compare March 15, 2017 11:53
@rawagner
Copy link
Member

testPR

   - Test run configuration requirements operates with multiple configurations
   - Single configuration xml file
   - Added processing of requirements without configuration
   - Only one configuration xml file is being work with
   - Support for nested suites
   - Support for property based requirements
   Tests:
   - Refactored tests:
      - PropertyBasedConfigurator
      - CustomConfigurator
      - TestRunConfigurationImpl
      - SuiteConfiguration
      - ParametriziedRequirementTest
      - RequirementsSequenceTest
      - InjectRequirementsBeforeRunIfTest
      - RedDeerSuiteTest
      - ComplexConfigurationTest
   - Unit tests for RequirementConfiguration
   - Unit tests for TestClassRequirementMap
   - Refactored tests failing due to changes
@odockal
Copy link
Member Author

odockal commented Mar 16, 2017

@rawagner commits squashed.

@rawagner rawagner merged commit 67fc981 into eclipse:master Mar 16, 2017
@odockal odockal deleted the reddeerReqConfig branch March 16, 2017 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants