Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@
<skipITs>false</skipITs>
<includes-failsafe>
**/ItCrossDomainTransaction,
**/ItKubernetesEvents,
**/ItKubernetesDomainEvents,
**/ItKubernetesNameSpaceWatchingEvents,
**/ItMiiAuxiliaryImage,
**/ItMiiAuxiliaryImageCluster,
**/ItMiiDomain,
Expand Down Expand Up @@ -500,7 +501,8 @@
<skipITs>false</skipITs>
<includes-failsafe>
**/ItCrossDomainTransaction,
**/ItKubernetesEvents,
**/ItKubernetesDomainEvents,
**/ItKubernetesNameSpaceWatchingEvents,
**/ItMiiAuxiliaryImage,
**/ItMiiAuxiliaryImageCluster,
**/ItMiiDomain,
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,21 @@ public static oracle.weblogic.domain.Domain getDomainCustomResource(String domai
return Domain.getDomainCustomResource(domainUid, namespace);
}

/**
* Get the Domain Custom Resource.
*
* @param domainUid unique domain identifier
* @param namespace name of namespace
* @param domainVersion version of domain
* @return Domain Custom Resource or null if Domain does not exist
* @throws ApiException if Kubernetes client API call fails
*/
public static oracle.weblogic.domain.Domain getDomainCustomResource(String domainUid,
String namespace,
String domainVersion) throws ApiException {
return Domain.getDomainCustomResource(domainUid, namespace, domainVersion);
}

/**
* Shutdown the domain.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ public static oracle.weblogic.domain.Domain getDomainCustomResource(String domai
return Kubernetes.getDomainCustomResource(domainUid, namespace);
}

/**
* Get a Domain Custom Resource.
*
* @param domainUid unique domain identifier
* @param namespace name of namespace
* @param domainVersion domain version
* @return domain custom resource or null if Domain does not exist
* @throws ApiException if Kubernetes request fails
*/
public static oracle.weblogic.domain.Domain getDomainCustomResource(String domainUid,
String namespace,
String domainVersion) throws ApiException {
return Kubernetes.getDomainCustomResource(domainUid, namespace, domainVersion);
}

/**
* Patch the Domain Custom Resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,39 @@ public static Domain getDomainCustomResource(String domainUid, String namespace)
return null;
}

/**
* Get the Domain Custom Resource.
*
* @param domainUid unique domain identifier
* @param namespace name of namespace
* @param domainVersion version of domain
* @return domain custom resource or null if Domain does not exist
* @throws ApiException if Kubernetes request fails
*/
public static Domain getDomainCustomResource(String domainUid, String namespace, String domainVersion)
throws ApiException {
Object domain;
try {
domain = customObjectsApi.getNamespacedCustomObject(
DOMAIN_GROUP, // custom resource's group name
domainVersion, // //custom resource's version
namespace, // custom resource's namespace
DOMAIN_PLURAL, // custom resource's plural name
domainUid // custom object's name
);
} catch (ApiException apex) {
getLogger().severe(apex.getResponseBody());
throw apex;
}

if (domain != null) {
return handleResponse(domain, Domain.class);
}

getLogger().warning("Domain Custom Resource '" + domainUid + "' not found in namespace " + namespace);
return null;
}

/**
* Patch the Domain Custom Resource using JSON Patch.JSON Patch is a format for describing changes to a JSON document
* using a series of operations. JSON Patch is specified in RFC 6902 from the IETF. For example, the following
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import oracle.weblogic.domain.Cluster;
import oracle.weblogic.domain.Configuration;
import oracle.weblogic.domain.Domain;
import oracle.weblogic.domain.DomainCondition;
import oracle.weblogic.domain.DomainSpec;
import oracle.weblogic.domain.Model;
import oracle.weblogic.domain.ServerPod;
Expand Down Expand Up @@ -80,6 +81,7 @@
import static oracle.weblogic.kubernetes.actions.TestActions.createConfigMap;
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
import static oracle.weblogic.kubernetes.actions.TestActions.deleteDomainCustomResource;
import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource;
import static oracle.weblogic.kubernetes.actions.TestActions.getJob;
import static oracle.weblogic.kubernetes.actions.TestActions.getPodLog;
import static oracle.weblogic.kubernetes.actions.TestActions.listPods;
Expand Down Expand Up @@ -749,4 +751,68 @@ public static void shutdownDomainAndVerify(String domainNamespace, String domain
}
}

/**
* Check the domain status condition type does not exist.
* @param domainUid uid of the domain
* @param domainNamespace namespace of the domain
* @param conditionType the type name of condition, accepted value: Completed, Available, Failed and
* ConfigChangesPendingRestart
* @return true if the condition type does not exist, false otherwise
*/
public static boolean verifyDomainStatusConditionTypeDoesNotExist(String domainUid,
String domainNamespace,
String conditionType) {
return verifyDomainStatusConditionTypeDoesNotExist(domainUid, domainNamespace,
conditionType, DOMAIN_VERSION);
}

/**
* Check the domain status condition type does not exist.
* @param domainUid uid of the domain
* @param domainNamespace namespace of the domain
* @param conditionType the type name of condition, accepted value: Completed, Available, Failed and
* ConfigChangesPendingRestart
* @param domainVersion version of domain
* @return true if the condition type does not exist, false otherwise
*/
public static boolean verifyDomainStatusConditionTypeDoesNotExist(String domainUid,
String domainNamespace,
String conditionType,
String domainVersion) {
Domain domain = assertDoesNotThrow(() -> getDomainCustomResource(domainUid, domainNamespace,
domainVersion));

if (domain != null && domain.getStatus() != null) {
List<DomainCondition> domainConditionList = domain.getStatus().getConditions();
for (DomainCondition domainCondition : domainConditionList) {
if (domainCondition.getType().equalsIgnoreCase(conditionType)) {
return false;
}
}
} else {
if (domain == null) {
getLogger().info("domain is null");
} else {
getLogger().info("domain status is null");
}
}
return true;
}

/**
* Obtains the specified domain, validates that it has a spec and no rolling condition.
* @param domainNamespace the namespace
* @param domainUid the UID
*/
@org.jetbrains.annotations.NotNull
public static Domain getAndValidateInitialDomain(String domainNamespace, String domainUid) {
Domain domain = assertDoesNotThrow(() -> getDomainCustomResource(domainUid, domainNamespace),
String.format("getDomainCustomResource failed "
+ "with ApiException when tried to get domain %s in namespace %s",
domainUid, domainNamespace));

assertNotNull(domain, "Got null domain resource");
assertNotNull(domain.getSpec(), domain + "/spec is null");
return domain;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static oracle.weblogic.kubernetes.actions.TestActions.getPodLog;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

Expand All @@ -35,6 +36,25 @@
public class K8sEvents {

private static final LoggingFacade logger = getLogger();
public static final String ABORTED_ERROR = "Domain processing is aborted";
public static final String DOMAIN_CREATED = "DomainCreated";
public static final String DOMAIN_DELETED = "DomainDeleted";
public static final String DOMAIN_CHANGED = "DomainChanged";
public static final String DOMAIN_FAILED = "DomainFailed";
public static final String DOMAIN_PROCESSING_STARTING = "DomainProcessingStarting";
public static final String DOMAIN_PROCESSING_COMPLETED = "DomainProcessingCompleted";
public static final String DOMAIN_PROCESSING_FAILED = "DomainProcessingFailed";
public static final String DOMAIN_PROCESSING_RETRYING = "DomainProcessingRetrying";
public static final String DOMAIN_PROCESSING_ABORTED = "DomainProcessingAborted";
public static final String DOMAIN_ROLL_STARTING = "DomainRollStarting";
public static final String DOMAIN_ROLL_COMPLETED = "DomainRollCompleted";
public static final String DOMAIN_VALIDATION_ERROR = "DomainValidationError";
public static final String NAMESPACE_WATCHING_STARTED = "NamespaceWatchingStarted";
public static final String NAMESPACE_WATCHING_STOPPED = "NamespaceWatchingStopped";
public static final String STOP_MANAGING_NAMESPACE = "StopManagingNamespace";
public static final String POD_TERMINATED = "Killing";
public static final String POD_STARTED = "Started";
public static final String POD_CYCLE_STARTING = "PodCycleStarting";

/**
* Utility method to check event.
Expand Down Expand Up @@ -492,23 +512,54 @@ private static void verifyOperatorDetails(
}
}

/**
* Check if a given DomainFailed event is logged by the operator.
*
* @param opNamespace namespace in which the operator is running
* @param domainNamespace namespace in which the domain exists
* @param domainUid UID of the domain
* @param failureReason DomainFailureReason to check
* @param type type of event, Normal of Warning
* @param timestamp the timestamp after which to see events
*/
public static Callable<Boolean> checkDomainFailedEventWithReason(
String opNamespace, String domainNamespace, String domainUid, String failureReason,
String type, OffsetDateTime timestamp) {
return () -> {
return domainFailedEventExists(opNamespace, domainNamespace, domainUid, failureReason, type, timestamp);
};
}

public static final String DOMAIN_CREATED = "DomainCreated";
public static final String DOMAIN_DELETED = "DomainDeleted";
public static final String DOMAIN_CHANGED = "DomainChanged";
public static final String DOMAIN_PROCESSING_STARTING = "DomainProcessingStarting";
public static final String DOMAIN_PROCESSING_COMPLETED = "DomainProcessingCompleted";
public static final String DOMAIN_PROCESSING_FAILED = "DomainProcessingFailed";
public static final String DOMAIN_PROCESSING_RETRYING = "DomainProcessingRetrying";
public static final String DOMAIN_PROCESSING_ABORTED = "DomainProcessingAborted";
public static final String DOMAIN_ROLL_STARTING = "DomainRollStarting";
public static final String DOMAIN_ROLL_COMPLETED = "DomainRollCompleted";
public static final String DOMAIN_VALIDATION_ERROR = "DomainValidationError";
public static final String NAMESPACE_WATCHING_STARTED = "NamespaceWatchingStarted";
public static final String NAMESPACE_WATCHING_STOPPED = "NamespaceWatchingStopped";
public static final String STOP_MANAGING_NAMESPACE = "StopManagingNamespace";
public static final String POD_TERMINATED = "Killing";
public static final String POD_STARTED = "Started";
public static final String POD_CYCLE_STARTING = "PodCycleStarting";
/**
* Check if a given event is logged by the operator in the given namespace.
*
* @param opNamespace namespace in which the operator is running
* @param domainNamespace namespace in which the event is logged
* @param domainUid UID of the domain
* @param failureReason failure reason to check
* @param type type of event, Normal or Warning
* @param timestamp the timestamp after which to see events
*/
public static boolean domainFailedEventExists(
String opNamespace, String domainNamespace, String domainUid, String failureReason,
String type, OffsetDateTime timestamp) {

try {
List<CoreV1Event> events = Kubernetes.listOpGeneratedNamespacedEvents(domainNamespace);
for (CoreV1Event event : events) {
if (DOMAIN_FAILED.equals(event.getReason()) && (isEqualOrAfter(timestamp, event))
&& event.getMessage().contains(failureReason)) {
logger.info(Yaml.dump(event));
verifyOperatorDetails(event, opNamespace, domainUid);
//verify type
logger.info("Verifying domain event type {0}", type);
assertEquals(event.getType(), type);
return true;
}
}
} catch (ApiException ex) {
logger.log(Level.SEVERE, null, ex);
}
return false;
}
}