Skip to content

Commit

Permalink
Issue #23507 nucleus-tests rebased to glassfish.zip and enabled
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <dmatej@seznam.cz>
  • Loading branch information
dmatej committed Apr 12, 2022
1 parent a22523c commit 9609096
Show file tree
Hide file tree
Showing 58 changed files with 1,749 additions and 1,513 deletions.
3 changes: 2 additions & 1 deletion nucleus/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021 Contributors to the Eclipse Foundation
Copyright (c) 2021-2022 Contributors to the Eclipse Foundation
Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -74,6 +74,7 @@
<module>diagnostics</module>
<module>resources</module>
<module>featuresets</module>
<module>tests</module>
</modules>

<scm>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<parent>
<groupId>org.glassfish.main.tests</groupId>
<artifactId>nucleus-tests</artifactId>
<version>@project.version@</version>
<relativePath>../../../../../pom.xml</relativePath>
<version>6.2.6-SNAPSHOT</version>
</parent>
<artifactId>test-progress-status-commands</artifactId>
<name>Progress status - Test Commands</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;

/** Basic progress status example.
/**
* Basic progress status example.
* Contains 10 steps
*
* @author mmares
Expand Down
93 changes: 42 additions & 51 deletions nucleus/tests/admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,6 @@
-->

<!--
INSTRUCTIONS for running nucleus admin dev tests.
To run all of the tests using the staged nucleus build in distributions/nucleus:
mvn test
To run just one test:
mvn -Dtest=MiscCommandsTest,NucleusStartStopTest test
Some tests require testing libraries/modules in running distribution. Please do
NOT start test against running instance.
To run tests based on your own install:
mvn -Dnucleus.home=...somedirectory/nucleus test
To see the output of a test run, look in the target/surefire-reports directory.
The TEST-TestSuite.xml file is especially useful.
INSTRUCTIONS for adding tests.
Copy one of the existing test files, such as MiscCommandsTest.java. Then add
tests. The file will automatically be picked up as part of the suite. There is
no need to modify this pom.xml file or any other configuration file. Useful
utilities are in the NucleusTestUtils class.
Test suit contains place for additional modules/libraries with testing content
that are copied into the Nucleus before start and removed after stop:
- src/addon/module/* -> <Nucleus>/modules
(If you need to add your testing module to different directory in nucleus than
modify org.glassfish.nucleus.admin.NucleusStartStopTest static initializer
of COPY_LIB map constant.)
-->
<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>

Expand Down Expand Up @@ -81,7 +48,6 @@ of COPY_LIB map constant.)
<artifactId>jersey-hk2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.main.admin</groupId>
<artifactId>rest-client</artifactId>
Expand All @@ -101,6 +67,29 @@ of COPY_LIB map constant.)
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<type>zip</type>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.tests</groupId>
<artifactId>test-progress-status-commands</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
Expand All @@ -114,30 +103,32 @@ of COPY_LIB map constant.)
<build>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<pomIncludes>
<pomInclude>modules/*/pom.xml</pomInclude>
<pomInclude>asadmin/*/pom.xml</pomInclude>
</pomIncludes>
<goals>
<goal>clean</goal>
<goal>package</goal>
</goals>
<projectsDirectory>${basedir}/src/addon/</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/addon</cloneProjectsTo>
</configuration>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>build-addons</id>
<phase>process-test-resources</phase>
<id>unpack-glassfish</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>glassfish</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
<execution>
<id>copy-addon</id>
<goals>
<goal>run</goal>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>test-progress-status-commands</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.build.directory}/glassfish6/glassfish/modules</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,38 +17,46 @@

package org.glassfish.nucleus.admin;

import static org.glassfish.tests.utils.NucleusTestUtils.getURL;
import static org.glassfish.tests.utils.NucleusTestUtils.matchString;
import static org.glassfish.tests.utils.NucleusTestUtils.nadmin;
import static org.testng.AssertJUnit.assertTrue;
import org.glassfish.nucleus.test.tool.DomainLifecycleExtension;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;

import org.testng.annotations.Test;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.getURL;
import static org.glassfish.nucleus.test.tool.NucleusTestUtils.nadmin;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
*
* @author Tom Mueller
*/
@Test(testName = "ClusterTest", enabled = true)
@TestMethodOrder(OrderAnnotation.class)
@ExtendWith(DomainLifecycleExtension.class)
public class ClusterTest {

final String tn = "QLCluster";
final String port1 = "55123";
final String port2 = "55124";
final String cname = "eec1";
final String i1name = "eein1-with-a-very-very-very-long-name";
final String i2name = "eein2";
String i1url = "http://localhost:" + port1;
String i2url = "http://localhost:" + port2;
private final String tn = "QLCluster";
private final String port1 = "55123";
private final String port2 = "55124";
private final String cname = "eec1";
private final String i1name = "eein1-with-a-very-very-very-long-name";
private final String i2name = "eein2";
private final String i1url = "http://localhost:" + port1;
private final String i2url = "http://localhost:" + port2;

@Test
@Order(1)
public void createClusterTest() {
// create a cluster and two instances
assertTrue("create cluster", nadmin("create-cluster", cname));
assertTrue(nadmin("create-cluster", cname), "create cluster");
}

@Test(dependsOnMethods = { "createClusterTest" })
@Test
@Order(2)
public void createInstancesTest() {
assertTrue("create instance1",
assertTrue(
nadmin("create-local-instance", "--cluster", cname, "--systemproperties",
"HTTP_LISTENER_PORT=" + port1 + ":" +
"HTTP_SSL_LISTENER_PORT=18181:" +
Expand All @@ -57,47 +66,52 @@ public void createInstancesTest() {
"IIOP_SSL_MUTUALAUTH_PORT=13801:" +
"JMS_PROVIDER_PORT=18686:" +
"ASADMIN_LISTENER_PORT=14848",
i1name));
i1name), "create instance1");

assertTrue("create instance2",
assertTrue(
nadmin("create-local-instance", "--cluster", cname, "--systemproperties",
"HTTP_LISTENER_PORT=" + port2 +
":HTTP_SSL_LISTENER_PORT=28181:IIOP_SSL_LISTENER_PORT=23800:" +
"IIOP_LISTENER_PORT=23700:JMX_SYSTEM_CONNECTOR_PORT=27676:IIOP_SSL_MUTUALAUTH_PORT=23801:" +
"JMS_PROVIDER_PORT=28686:ASADMIN_LISTENER_PORT=24848",
i2name));
i2name), "create instance2");
}

@Test(dependsOnMethods = { "createInstancesTest" })
@Test
@Order(3)
public void startInstancesTest() {
// start the instances
assertTrue("start instance1", nadmin("start-local-instance", i1name));
assertTrue("start instance2", nadmin("start-local-instance", i2name));
assertTrue(nadmin("start-local-instance", i1name), "start instance1");
assertTrue(nadmin("start-local-instance", i2name), "start instance2");
}

@Test(dependsOnMethods = { "startInstancesTest" })
@Test
@Order(4)
public void checkClusterTest() {
// check that the instances are there
assertTrue("list-instances", nadmin("list-instances"));
assertTrue("getindex1", matchString("GlassFish Server", getURL(i1url)));
assertTrue("getindex2", matchString("GlassFish Server", getURL(i2url)));
assertTrue(nadmin("list-instances"), "list-instances");
assertThat(getURL(i1url), stringContainsInOrder("GlassFish Server"));
assertThat(getURL(i2url), stringContainsInOrder("GlassFish Server"));
}

@Test(dependsOnMethods = { "checkClusterTest" })
@Test
@Order(5)
public void stopInstancesTest() {
// stop and delete the instances and cluster
assertTrue("stop instance1", nadmin("stop-local-instance", "--kill", i1name));
assertTrue("stop instance2", nadmin("stop-local-instance", "--kill", i2name));
assertTrue(nadmin("stop-local-instance", "--kill", i1name), "stop instance1");
assertTrue(nadmin("stop-local-instance", "--kill", i2name), "stop instance2");
}

@Test(dependsOnMethods = { "stopInstancesTest" })
@Test
@Order(6)
public void deleteInstancesTest() {
assertTrue("delete instance1", nadmin("delete-local-instance", i1name));
assertTrue("delete instance2", nadmin("delete-local-instance", i2name));
assertTrue(nadmin("delete-local-instance", i1name), "delete instance1");
assertTrue(nadmin("delete-local-instance", i2name), "delete instance2");
}

@Test(dependsOnMethods = { "deleteInstancesTest" })
@Test
@Order(7)
public void deleteClusterTest() {
assertTrue("delete cluster", nadmin("delete-cluster", cname));
assertTrue(nadmin("delete-cluster", cname), "delete cluster");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,29 +17,40 @@

package org.glassfish.nucleus.admin;

import static org.glassfish.tests.utils.NucleusTestUtils.*;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test;
import org.glassfish.nucleus.test.tool.DomainLifecycleExtension;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.glassfish.nucleus.test.tool.NucleusTestUtils.nadmin;
import static org.junit.jupiter.api.Assertions.assertTrue;


/**
*
* @author Tom Mueller
*/
@Test(testName="MiscCommandsTest")
@ExtendWith(DomainLifecycleExtension.class)
@TestMethodOrder(OrderAnnotation.class)
public class MiscCommandsTest {

@Test
@Order(1)
public void uptime() {
assertTrue(nadmin("uptime"));
}

@Test
@Order(1)
public void version1() {
assertTrue(nadmin("version"));
}

@Test
@Order(100)
public void version2() {
assertTrue(nadmin("stop-domain"));
assertTrue(nadmin("version", "--local"));
assertTrue(nadmin("start-domain"));
}

}

0 comments on commit 9609096

Please sign in to comment.