Search in sources :

Example 1 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class WlsDomainConfigTest method verifyUpdateDomainSpecNoWarningIfReplicasOK.

@Test
public void verifyUpdateDomainSpecNoWarningIfReplicasOK() throws Exception {
    WlsDomainConfig wlsDomainConfig = WlsDomainConfig.create().load(JSON_STRING_1_CLUSTER);
    DomainSpec domainSpec = new DomainSpec().withClusterStartup(Arrays.asList(new ClusterStartup().withClusterName("DockerCluster"))).withReplicas(5);
    TestUtil.LogHandlerImpl handler = null;
    WlsClusterConfig wlsClusterConfig = wlsDomainConfig.getClusterConfig("DockerCluster");
    try {
        handler = TestUtil.setupLogHandler(wlsClusterConfig);
        wlsDomainConfig.updateDomainSpecAsNeeded(domainSpec);
        assertFalse(handler.hasWarningMessageLogged());
    } finally {
        TestUtil.removeLogHandler(wlsClusterConfig, handler);
    }
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) ClusterStartup(oracle.kubernetes.weblogic.domain.v1.ClusterStartup) Test(org.junit.Test)

Example 2 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class WlsDomainConfigTest method verifyUpdateDomainSpecWarnsIfClusterStatupReplicasTooLarge.

@Test
public void verifyUpdateDomainSpecWarnsIfClusterStatupReplicasTooLarge() throws Exception {
    WlsDomainConfig wlsDomainConfig = WlsDomainConfig.create().load(JSON_STRING_2_CLUSTERS);
    DomainSpec domainSpec = new DomainSpec().withClusterStartup(Arrays.asList(new ClusterStartup().withClusterName("DockerCluster2").withReplicas(3))).withReplicas(5);
    TestUtil.LogHandlerImpl handler = null;
    WlsClusterConfig wlsClusterConfig = wlsDomainConfig.getClusterConfig("DockerCluster2");
    try {
        handler = TestUtil.setupLogHandler(wlsClusterConfig);
        wlsDomainConfig.updateDomainSpecAsNeeded(domainSpec);
        assertTrue("Message logged: " + handler.getAllFormattedMessage(), handler.hasWarningMessageWithSubString("Replicas in clusterStartup for cluster DockerCluster2 is specified with a value of 3 which is larger than the number of configured WLS servers in the cluster: 2"));
    } finally {
        TestUtil.removeLogHandler(wlsClusterConfig, handler);
    }
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) ClusterStartup(oracle.kubernetes.weblogic.domain.v1.ClusterStartup) Test(org.junit.Test)

Example 3 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class WlsDomainConfigTest method verifyUpdateDomainSpecNoWarningIfClusterStatupReplicasOK.

@Test
public void verifyUpdateDomainSpecNoWarningIfClusterStatupReplicasOK() throws Exception {
    WlsDomainConfig wlsDomainConfig = WlsDomainConfig.create().load(JSON_STRING_2_CLUSTERS);
    DomainSpec domainSpec = new DomainSpec().withClusterStartup(Arrays.asList(new ClusterStartup().withClusterName("DockerCluster2").withReplicas(2))).withReplicas(5);
    TestUtil.LogHandlerImpl handler = null;
    WlsClusterConfig wlsClusterConfig = wlsDomainConfig.getClusterConfig("DockerCluster2");
    try {
        handler = TestUtil.setupLogHandler(wlsClusterConfig);
        wlsDomainConfig.updateDomainSpecAsNeeded(domainSpec);
        assertFalse(handler.hasWarningMessageLogged());
    } finally {
        TestUtil.removeLogHandler(wlsClusterConfig, handler);
    }
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) ClusterStartup(oracle.kubernetes.weblogic.domain.v1.ClusterStartup) Test(org.junit.Test)

Example 4 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class WlsDomainConfigTest method verifyUpdateDomainSpecWarnsIfReplicasTooLarge.

@Test
public void verifyUpdateDomainSpecWarnsIfReplicasTooLarge() throws Exception {
    WlsDomainConfig wlsDomainConfig = WlsDomainConfig.create().load(JSON_STRING_1_CLUSTER);
    DomainSpec domainSpec = new DomainSpec().withClusterStartup(Arrays.asList(new ClusterStartup().withClusterName("DockerCluster"))).withReplicas(10);
    TestUtil.LogHandlerImpl handler = null;
    WlsClusterConfig wlsClusterConfig = wlsDomainConfig.getClusterConfig("DockerCluster");
    try {
        handler = TestUtil.setupLogHandler(wlsClusterConfig);
        wlsDomainConfig.updateDomainSpecAsNeeded(domainSpec);
        assertTrue("Message logged: " + handler.getAllFormattedMessage(), handler.hasWarningMessageWithSubString("Replicas in domainSpec for cluster DockerCluster is specified with a value of 10 which is larger than the number of configured WLS servers in the cluster: 5"));
    } finally {
        TestUtil.removeLogHandler(wlsClusterConfig, handler);
    }
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) ClusterStartup(oracle.kubernetes.weblogic.domain.v1.ClusterStartup) Test(org.junit.Test)

Example 5 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class Main method adminChannelsToCreate.

/**
 * This method checks the domain spec against any configured network
 * access points defined for the domain. This implementation only handles T3
 * protocol for externalization.
 *
 * @param scan      WlsDomainConfig from discovery containing configuration
 * @param dom       Domain containing Domain resource information
 * @return Validated collection of network access points
 */
public static Collection<NetworkAccessPoint> adminChannelsToCreate(WlsDomainConfig scan, Domain dom) {
    LOGGER.entering();
    // The following hard-coded values for the nodePort min/max ranges are
    // provided here until the appropriate API is discovered to obtain
    // this information from Kubernetes.
    Integer nodePortMin = 30000;
    Integer nodePortMax = 32767;
    DomainSpec spec = dom.getSpec();
    if (spec.getExportT3Channels() == null) {
        return null;
    }
    WlsServerConfig adminServerConfig = scan.getServerConfig(spec.getAsName());
    List<NetworkAccessPoint> naps = adminServerConfig.getNetworkAccessPoints();
    // This will become a list of valid channels to create services for.
    Collection<NetworkAccessPoint> channels = new ArrayList<>();
    // Pick out externalized channels from the server channels list
    for (String incomingChannel : spec.getExportT3Channels()) {
        boolean missingChannel = true;
        for (NetworkAccessPoint nap : naps) {
            if (nap.getName().equalsIgnoreCase(incomingChannel)) {
                missingChannel = false;
                channels.add(nap);
                break;
            }
        }
        if (missingChannel) {
            LOGGER.warning(MessageKeys.EXCH_CHANNEL_NOT_DEFINED, incomingChannel, spec.getAsName());
        }
    }
    // Iterate through the selected channels and validate
    Collection<NetworkAccessPoint> validatedChannels = new ArrayList<>();
    for (NetworkAccessPoint nap : channels) {
        // Only supporting T3 for now.
        if (!nap.getProtocol().equalsIgnoreCase("t3")) {
            LOGGER.severe(MessageKeys.EXCH_WRONG_PROTOCOL, nap.getName(), nap.getProtocol());
            continue;
        }
        // Until otherwise determined, ports must be the same.
        if (!nap.getListenPort().equals(nap.getPublicPort())) {
            // log a warning and ignore this item.
            LOGGER.warning(MessageKeys.EXCH_UNEQUAL_LISTEN_PORTS, nap.getName());
            continue;
        }
        // Make sure configured port is within NodePort range.
        if (nap.getListenPort().compareTo(nodePortMin) < 0 || nap.getListenPort().compareTo(nodePortMax) > 0) {
            // port setting is outside the NodePort range limits
            LOGGER.warning(MessageKeys.EXCH_OUTSIDE_RANGE, nap.getName(), nap.getPublicPort(), nodePortMin, nodePortMax);
            continue;
        }
        validatedChannels.add(nap);
    }
    LOGGER.exiting();
    return validatedChannels;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WlsServerConfig(oracle.kubernetes.operator.wlsconfig.WlsServerConfig) DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) NetworkAccessPoint(oracle.kubernetes.operator.wlsconfig.NetworkAccessPoint) ArrayList(java.util.ArrayList)

Aggregations

DomainSpec (oracle.kubernetes.weblogic.domain.v1.DomainSpec)17 ClusterStartup (oracle.kubernetes.weblogic.domain.v1.ClusterStartup)11 Test (org.junit.Test)10 Domain (oracle.kubernetes.weblogic.domain.v1.Domain)6 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)3 V1Service (io.kubernetes.client.models.V1Service)2 ArrayList (java.util.ArrayList)2 DomainPresenceInfo (oracle.kubernetes.operator.helpers.DomainPresenceInfo)2 WlsServerConfig (oracle.kubernetes.operator.wlsconfig.WlsServerConfig)2 Engine (oracle.kubernetes.operator.work.Engine)2 Packet (oracle.kubernetes.operator.work.Packet)2 Step (oracle.kubernetes.operator.work.Step)2 V1ConfigMap (io.kubernetes.client.models.V1ConfigMap)1 V1EnvVar (io.kubernetes.client.models.V1EnvVar)1 V1ServiceList (io.kubernetes.client.models.V1ServiceList)1 V1ServicePort (io.kubernetes.client.models.V1ServicePort)1 V1ServiceSpec (io.kubernetes.client.models.V1ServiceSpec)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1