forked from objectionary/opeo-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(objectionary#200): add large integration test skeleton
- Loading branch information
1 parent
f3e94e8
commit 7824c3e
Showing
6 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Full Spring Fat Jar Integration Test | ||
|
||
This integration test verifies all the phases of the | ||
`opeo-maven-plugin` together with `jeo-maven-plugin` and `ineo-maven-plugin`. | ||
In this test we use created Spring Framework based application, build a fat jar | ||
application and then apply all the transformations and optimizations to it. | ||
|
||
The distinctive aspect of this test is its comprehensive process of handling | ||
dependencies: it downloads all required dependencies, unpacks them, applies | ||
transformations via the `jeo-maven-plugin`, and then tries to decompile the | ||
`jeo` representation via `opeo-maven-plugin:decompile`, then we apply | ||
oprimization via `ineo-maven-plugin:optimize` then we compile the optimized | ||
representation back to the original representation | ||
via `opeo-maven-plugin:compile`, then we assemble the compiled `jeo` | ||
representation back to bytecode | ||
by utilizing `jeo-maven-plugin:assemble"`. By doing this we can verify that | ||
that `opeo-maven-plugin` does not break the application and all its | ||
dependencies. | ||
|
||
In short, the process is as follows: | ||
|
||
1. **Compile the application and download all it's dependencies** | ||
2. **Unpack dependencies** | ||
3. **Disassemble**: Apply transformation via the `jeo-maven-plugin:dissassemble` | ||
goal for all the unpacked dependencies including the application itself. | ||
4. **Decompile**: Apply decompilation via the `opeo-maven-plugin:decompile` goal | ||
5. **Optimize**: Apply optimization via the `ineo-maven-plugin:optimize` goal | ||
6. **Compile**: Apply compilation via the `opeo-maven-plugin:compile` goal | ||
7. **Assemble**: Apply back transformation via the `jeo-maven-plugin:assemble` | ||
goal | ||
8. **Build the application**: Compiles the optimizaed application back into a | ||
fat jar. | ||
9. **Run the application**: Run the optimized application to verify that it | ||
works correctly. | ||
|
||
To exclusively run this test, execute the command below: | ||
|
||
```shell | ||
mvn clean integration-test invoker:run -Dinvoker.test=spring-fat -DskipTests | ||
``` | ||
|
||
## The First Results | ||
|
||
Here is the summary of the first results of the `spring-fat` integration test: | ||
|
||
- The application starts and runs successfully. //todo | ||
- The average test time is approximately **TODO seconds**. | ||
- The total number of classes is **TODO**. | ||
- The Disassembly phase takes approximately **TODO minutes**. | ||
- The Decompile phase takes approximately **TODO minutes**. | ||
- The Compile phase takes approximately **TODO minutes**. | ||
- The Assembly phase takes approximately **TODO minutes**. | ||
|
||
## Developer Notes | ||
|
||
### Excluded from the default build pipeline | ||
|
||
This test remains rather long and has not yet been optimized. As a result, it | ||
is excluded from the default build pipeline. To run this test alongside all | ||
others, you need to activate the `long` Maven profile. Use the command below: | ||
|
||
```bash | ||
mvn clean install -Plong | ||
``` | ||
|
||
### Bytecode verification | ||
|
||
Some Spring Boot components were compiled with optional dependencies, and these | ||
dependencies are not present in the corresponding POM files. Therefore, we | ||
cannot find these dependencies during the test. However, the current | ||
implementation of bytecode verification requires that all classes are loaded by | ||
the `ClassLoader` before verification, which is not possible in this case. As a | ||
result, we skip bytecode verification for this test. | ||
|
||
```xml | ||
|
||
<skipVerification>true</skipVerification> | ||
``` | ||
|
||
You can read more about this problem [in | ||
the `jeo-maven-plugin` configuration](https://github.com/objectionary/jeo-maven-plugin/tree/master/src/it/spring-fat#bytecode-verification). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=clean process-classes -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
The MIT License (MIT) | ||
Copyright (c) 2016-2023 Objectionary.com | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<!-- | ||
The version of 3.2.0 and similar requires rather high java | ||
version: 17 or higher. So we intentionally use the version 2.7.18 | ||
here that requires java 11 since our plugin should be compatible with | ||
java 11. | ||
--> | ||
<version>2.7.18</version> | ||
<relativePath/> | ||
</parent> | ||
<groupId>org.eolang</groupId> | ||
<artifactId>jeo-spring-fat-it</artifactId> | ||
<version>@project.version@</version> | ||
<packaging>jar</packaging> | ||
<description> | ||
Integration test that checks correct transformation of an application written with using of the Springs Framework. | ||
This integration test starts the application with several beans and prints results to the console. | ||
This is a similar integration test with the "spring" test in the "src/it/spring" test. | ||
The only difference is that in this test we download all the dependencies, unpack them, transform using jeo-maven-plugin | ||
and then pack them back. In other words, we test the fat jar transformation. | ||
If you need to run only this test, use the following command: | ||
"mvn clean integration-test invoker:run -Dinvoker.test=spring-fat -DskipTests" | ||
</description> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.6.1</version> | ||
<executions> | ||
<execution> | ||
<id>unpack-dependencies</id> | ||
<goals> | ||
<goal>unpack-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.outputDirectory}</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eolang</groupId> | ||
<artifactId>jeo-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<disabled>false</disabled> | ||
<!-- | ||
@todo #488:90min Enable Bytecode Verification For Spring Fat Integration Test. | ||
We skip verification because the Spring Framework uses many classes that | ||
are not in the classpath and the plugin cannot verify the correctness of | ||
the transformation. For not it's not so crucial, but in the future, we | ||
should enable it. | ||
--> | ||
<skipVerification>true</skipVerification> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>bytecode-to-eo</id> | ||
<goals> | ||
<goal>disassemble</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>eo-to-bytecode</id> | ||
<goals> | ||
<goal>assemble</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<executions> | ||
<execution> | ||
<phase> | ||
process-classes | ||
</phase> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<executable>java</executable> | ||
<arguments> | ||
<argument>-classpath</argument> | ||
<argument>${project.build.outputDirectory}</argument> | ||
<argument>org.eolang.jeo.spring.Application</argument> | ||
</arguments> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
49 changes: 49 additions & 0 deletions
49
src/it/spring-fat/src/main/java/org/eolang/jeo/spring/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016-2023 Objectionary.com | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.eolang.jeo.spring; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* Spring Application Entry Point. | ||
* @since 0.2 | ||
*/ | ||
@SpringBootApplication | ||
public class Application implements CommandLineRunner { | ||
|
||
@Autowired | ||
private Receptionist receptionist; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
@Override | ||
public void run(final String... args) { | ||
this.receptionist.sayHello("Fat Spring"); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/it/spring-fat/src/main/java/org/eolang/jeo/spring/Receptionist.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016-2023 Objectionary.com | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.eolang.jeo.spring; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Greeter bean. | ||
* @since 0.2 | ||
*/ | ||
@Component | ||
public class Receptionist { | ||
public void sayHello(final String who) { | ||
System.out.printf("Glad to see you, %s...%n", who); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2016-2023 Objectionary.com | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
//Check logs first. | ||
String log = new File(basedir, 'build.log').text; | ||
assert log.contains("BUILD SUCCESS") | ||
assert log.contains("Glad to see you, Fat Spring...") | ||
true |