Skip to content

Commit

Permalink
[WIP] Automate MTA-404 custom rules with source technology
Browse files Browse the repository at this point in the history
Signed-off-by: Karishma Punwatkar <[email protected]>

	modified:   cypress/e2e/tests/administration/custom-migration-targets/crud.test.ts
	modified:   cypress/fixtures/custom-rules.json
	new file:   cypress/fixtures/xml/corporate-framework-config.windup.xml
  • Loading branch information
kpunwatk committed Mar 15, 2024
1 parent af241ee commit a2ee112
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,48 @@ describe(["@tier1", "@dc", "@interop"], "Custom Migration Targets CRUD operation
application.delete();
});
});

Object.values(Languages).forEach((language) => {
it(`${language} | custom rule with source technology`, function () {
const targetData = this.customMigrationTargets["rules_with_source_element"];
const target = new CustomMigrationTarget(
data.getRandomWord(8),
data.getDescription(),
targetData.image,
getRulesData(targetData),
language
);
target.create();

const application = new Analysis(
getRandomApplicationData("bookserverApp", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["source_analysis_on_bookserverapp"])
);

// ToDo add validation to check source technology in advance option

application.create();

Analysis.open();
selectItemsPerPage(100);
application.selectApplication();
cy.contains(button, analyzeButton, { timeout: 20 * SEC })
.should("be.enabled")
.click();

application.selectSourceofAnalysis(application.source);
cy.contains(button, "Next", { timeout: 200 }).click();

Analysis.selectLanguage(language);
cy.get(".pf-v5-c-card__body", { timeout: 12 * SEC })
.first()
.should("contain", target.name);
clickByText(button, "Cancel");

target.delete();
application.delete();
});
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/custom-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@
"hazelcast_target": {
"image": "img/cloud.png",
"rulesFiles": ["xml/hazelcast.windup.xml"]
},

"rules_with_source_element": {
"image": "img/cloud.png",
"rulesFiles": ["xml/corporate-framework-config.windup.xml"]
}
}
64 changes: 64 additions & 0 deletions cypress/fixtures/xml/corporate-framework-config.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0"?>
<ruleset id="corporate-configuration"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<description>
This ruleset provides rules related to the corporate configuration frameworks.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final"/>
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final"/>
</dependencies>
<sourceTechnology id="traditional-corporate-framework"/>
<targetTechnology id="cloud-corporate-framework"/>
<tag>configuration</tag>
</metadata>
<rules>
<rule id="corporate-config-01000" xmlns="http://windup.jboss.org/schema/jboss-ruleset">
<when>
<javaclass references="io.konveyor.demo.config.ApplicationConfiguration">
<location>VARIABLE_DECLARATION</location>
</javaclass>
</when>
<perform>
<hint title="Legacy configuration with io.konveyor.demo.config.ApplicationConfiguration" effort="1" category-id="cloud-mandatory">
<message>
The legacy ApplicationConfiguration class is being used in this application. This is discouraged by the migration
guidelines, and should be replaced by a more standard approach using Spring's @PropertySource annotation and Environment class:


```java
@PropertySource("classpath:persistence.properties")
public class PersistenceConfig {
@Autowired
private Environment env;

@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.user"));
dataSource.setPassword(env.getProperty("jdbc.password"));

return dataSource;
}
}
```



This allows externalizing the configuration in Kubernetes by injecting it as a ConfigMap or a Secret in the lib directory from the
container running the Tomcat instance.
</message>
<link title="Spring Documentation - PropertySource javadoc" href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html"/>
<link title="Mkyong - Spring @PropertySource example" href="https://mkyong.com/spring/spring-propertysources-example/"/>
<link title="Baeldung - Properties with Spring and Spring Boot" href="https://www.baeldung.com/properties-with-spring" />
<tag>configuration</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>

0 comments on commit a2ee112

Please sign in to comment.