Skip to content

Commit

Permalink
Disable feature generation (#1492)
Browse files Browse the repository at this point in the history
* Disable feature generation

Signed-off-by: Kathryn Kodama <kathryn.s.kodama@gmail.com>

* Diable feature generation checks in dev integration tests

Signed-off-by: Kathryn Kodama <kathryn.s.kodama@gmail.com>

* exclude generate-features-it

Signed-off-by: Kathryn Kodama <kathryn.s.kodama@gmail.com>
  • Loading branch information
kathrynkodama committed Apr 25, 2022
1 parent ed1a588 commit 348ff67
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 18 deletions.
10 changes: 10 additions & 0 deletions liberty-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<pomExcludes>
<!--TODO remove when feature generation is re-enabled-->
<pomExclude>generate-features-it/pom.xml</pomExclude>
</pomExcludes>
<debug>false</debug>
<goals>
<goal>install</goal>
Expand Down Expand Up @@ -165,6 +169,10 @@
<artifactId>maven-invoker-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<pomExcludes>
<!--TODO remove when feature generation is re-enabled-->
<pomExclude>generate-features-it/pom.xml</pomExclude>
</pomExcludes>
<debug>false</debug>
<goals>
<goal>install</goal>
Expand Down Expand Up @@ -245,6 +253,8 @@
<pomExclude>server-param-default-it/pom.xml</pomExclude>
<pomExclude>server-param-configdir-override-it/pom.xml</pomExclude>
<pomExclude>install-features-it/pom.xml</pomExclude>
<!--TODO remove when feature generation is re-enabled-->
<pomExclude>generate-features-it/pom.xml</pomExclude>
</pomExcludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

/**
* Start dev mode, update umbrella dependencies in the pom.xml, ensure that the correct version
* of features are generated
*/
// TODO enable when feature generation is re-enabled
@Ignore
public class DevGenerateFeaturesDependenciesTest extends BaseDevTest {

@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public void basicTest() throws Exception {

@Test
public void configChangeTest() throws Exception {
int generateFeaturesCount = countOccurrences(RUNNING_GENERATE_FEATURES, logFile);
// TODO enable when feature generation is re-enabled
// int generateFeaturesCount = countOccurrences(RUNNING_GENERATE_FEATURES, logFile);

// configuration file change
File srcServerXML = new File(tempProj, "/src/main/liberty/config/server.xml");
File targetServerXML = new File(targetDir, "/liberty/wlp/usr/servers/defaultServer/server.xml");
Expand All @@ -65,8 +67,9 @@ public void configChangeTest() throws Exception {

replaceString("</feature>", "</feature>\n" + " <feature>mpFaultTolerance-2.0</feature>", srcServerXML);

// TODO enable when feature generation is re-enabled
// check that features have been generated
assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 10000, ++generateFeaturesCount)); // mojo ran
// assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 10000, ++generateFeaturesCount)); // mojo ran

// check for server configuration was successfully updated message
assertTrue(verifyLogMessageExists("CWWKG0017I", 60000));
Expand All @@ -78,16 +81,18 @@ public void configChangeTest() throws Exception {
public void configIncludesChangeTest() throws Exception {
// add a feature to an <includes> server configuration file, ensure that
// generate-features is called and the server configuration is updated
int generateFeaturesCount = countOccurrences(RUNNING_GENERATE_FEATURES, logFile);
// TODO enable when feature generation is re-enabled
// int generateFeaturesCount = countOccurrences(RUNNING_GENERATE_FEATURES, logFile);
File srcServerXMLIncludes = new File(tempProj, "/src/main/liberty/config/extraFeatures.xml");
File targetServerXMLIncludes = new File(targetDir, "/liberty/wlp/usr/servers/defaultServer/extraFeatures.xml");
assertTrue(srcServerXMLIncludes.exists());
assertTrue(targetServerXMLIncludes.exists());

replaceString("<!-- replace -->", "<feature>servlet-4.0</feature>", srcServerXMLIncludes);

// TODO enable when feature generation is re-enabled
// check that features have been generated
assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 10000, ++generateFeaturesCount)); // mojo ran
// assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 10000, ++generateFeaturesCount)); // mojo ran

// check for server configuration was successfully updated message
assertTrue(verifyLogMessageExists("CWWKG0017I", 60000));
Expand Down Expand Up @@ -163,15 +168,18 @@ public void manualTestsInvocationTest() throws Exception {

@Test
public void restartServerTest() throws Exception {
int runningGenerateCount = countOccurrences(RUNNING_GENERATE_FEATURES, logFile);
// TODO enable when feature generation is re-enabled
// int runningGenerateCount = countOccurrences(RUNNING_GENERATE_FEATURES, logFile);
String RESTARTED = "The server has been restarted.";
int restartedCount = countOccurrences(RESTARTED, logFile);
writer.write("r\n"); // command to restart liberty
writer.flush();

assertTrue(verifyLogMessageExists(RESTARTED, 20000, ++restartedCount));

// TODO enable when feature generation is re-enabled
// not supposed to rerun generate features just because of a server restart
assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 2000, runningGenerateCount));
// assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 2000, runningGenerateCount));
}

@Test
Expand Down Expand Up @@ -232,7 +240,9 @@ public void resolveDependencyTest() throws Exception {
assertTrue(getLogTail(), verifyFileExists(systemHealthTarget, 15000));
}

// TODO enable when feature generation is re-enabled
@Test
@Ignore
public void generateFeatureTest() throws Exception {
final String SERVER_XML_COMMENT = "Plugin has generated Liberty features"; // the explanation added to server.xml
final String NEW_FILE_INFO_MESSAGE = "This file was generated by the Liberty Maven Plugin and will be overwritten"; // the explanation added to the generated features file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public void updatePomsTest() throws Exception {
int warTestsCount = countOccurrences("guide-maven-multimodules-war tests compilation was successful.", logFile);
int earTestsCount = countOccurrences("guide-maven-multimodules-ear tests compilation was successful.", logFile);

// TODO enable when feature generation is re-enabled
// verify that generated-features.xml file exists
File newFeatureFile = getGeneratedFeaturesFile("ear");
assertTrue(getLogTail(), verifyFileExists(newFeatureFile, 1000));
long newFeatureFileLastModified = newFeatureFile.lastModified();
// File newFeatureFile = getGeneratedFeaturesFile("ear");
// assertTrue(getLogTail(), verifyFileExists(newFeatureFile, 1000));
// long newFeatureFileLastModified = newFeatureFile.lastModified();
waitLongEnough();

touchFileTwice("jar/pom.xml");
Expand All @@ -77,9 +78,10 @@ public void updatePomsTest() throws Exception {
assertEquals(getLogTail(), ++earTestsCount,
countOccurrences("guide-maven-multimodules-ear tests compilation was successful.", logFile));

// TODO enable when feature generation is re-enabled
// verify that feature generation ran
assertTrue(getLogTail(), waitForCompilation(newFeatureFile, newFeatureFileLastModified, 1000));
newFeatureFileLastModified = newFeatureFile.lastModified();
// assertTrue(getLogTail(), waitForCompilation(newFeatureFile, newFeatureFileLastModified, 1000));
// newFeatureFileLastModified = newFeatureFile.lastModified();
waitLongEnough();

touchFileTwice("war/pom.xml");
Expand All @@ -100,9 +102,10 @@ public void updatePomsTest() throws Exception {
assertEquals(getLogTail(), ++earTestsCount,
countOccurrences("guide-maven-multimodules-ear tests compilation was successful.", logFile));

// TODO enable when feature generation is re-enabled
// verify that feature generation ran
assertTrue(getLogTail(), waitForCompilation(newFeatureFile, newFeatureFileLastModified, 1000));
newFeatureFileLastModified = newFeatureFile.lastModified();
// assertTrue(getLogTail(), waitForCompilation(newFeatureFile, newFeatureFileLastModified, 1000));
// newFeatureFileLastModified = newFeatureFile.lastModified();
waitLongEnough();

touchFileTwice("ear/pom.xml");
Expand All @@ -123,9 +126,10 @@ public void updatePomsTest() throws Exception {
assertEquals(getLogTail(), ++earTestsCount,
countOccurrences("guide-maven-multimodules-ear tests compilation was successful.", logFile));

// TODO enable when feature generation is re-enabled
// verify that feature generation did not run since there are no source class
// files for the ear module
assertEquals("generated-features.xml was modified\n" + getLogTail(), newFeatureFileLastModified, newFeatureFile.lastModified());
// assertEquals("generated-features.xml was modified\n" + getLogTail(), newFeatureFileLastModified, newFeatureFile.lastModified());
}

private void touchFileTwice(String path) throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public class DevMojo extends LooseAppSupport {
@Parameter(property = "container", defaultValue = "false")
private boolean container;

@Parameter(property = "generateFeatures", defaultValue = "true")
private boolean generateFeatures;
// TODO enable when feature generation is re-enabled
// @Parameter(property = "generateFeatures", defaultValue = "true")
// private boolean generateFeatures;

/**
* Whether to recompile dependencies. Defaults to false for single module
Expand Down Expand Up @@ -272,7 +273,6 @@ protected List<File> getResourceDirectories(MavenProject project, File outputDir
}

private class DevMojoUtil extends DevUtil {

Set<String> existingFeatures;
Map<String, File> libertyDirPropertyFiles = new HashMap<String, File>();
List<MavenProject> upstreamMavenProjects;
Expand Down Expand Up @@ -1116,6 +1116,10 @@ private boolean isUsingBoost() {

@Override
protected void doExecute() throws Exception {
// TODO remove once feature generation is re-enabled
// force generateFeatures = false to disable feature generation
boolean generateFeatures = false;

if (skip) {
getLog().info("\nSkipping dev goal.\n");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
* in the featureManager elements in the XML configuration files. Then it generates any
* missing feature names and stores them in a new featureManager element in a new XML file.
*/
@Mojo(name = "generate-features")
// TODO enable when feature generation is re-enabled
// disable generate-features Mojo (remove liberty:generate-features goal)
// @Mojo(name = "generate-features")
public class GenerateFeaturesMojo extends ServerFeatureSupport {

public static final String FEATURES_FILE_MESSAGE = "The Liberty Maven Plugin has generated Liberty features necessary for your application in "
Expand Down

0 comments on commit 348ff67

Please sign in to comment.