diff --git a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager.ivt/build.gradle b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager.ivt/build.gradle index 1a9cc75f9..7373fc01c 100644 --- a/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager.ivt/build.gradle +++ b/galasa-managers-parent/galasa-managers-cicsts-parent/dev.galasa.cicsts.manager.ivt/build.gradle @@ -4,7 +4,7 @@ plugins { description = 'Galasa CICS TS Manager IVTs' -version = '0.25.0' +version = '0.38.0' dependencies { implementation project (':galasa-managers-core-parent:dev.galasa.core.manager') @@ -12,7 +12,6 @@ dependencies { implementation project (':galasa-managers-zos-parent:dev.galasa.zos.manager') implementation project (':galasa-managers-zos-parent:dev.galasa.zos3270.manager') implementation project (':galasa-managers-workflow-parent:dev.galasa.githubissue.manager') - implementation project (':galasa-managers-internal-parent:dev.galasa.sem.manager') } // Note: These values are consumed by the parent build process diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/bnd.bnd b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/bnd.bnd deleted file mode 100644 index 51244e010..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/bnd.bnd +++ /dev/null @@ -1,20 +0,0 @@ --snapshot: ${tstamp} -Bundle-Name: Galasa Internal SEM Manager -Export-Package: dev.galasa.sem -Import-Package: dev.galasa.*,\ - org.apache.commons.logging,\ - org.apache.velocity*,\ - org.apache.logging.*,\ - org.w3c.dom,\ - org.xml.sax,\ - org.xml.sax.ext,\ - org.xml.sax.helpers,\ - javax.xml.datatype,\ - javax.xml.namespace,\ - javax.xml.parsers --includeresource: sem.jar; lib:=true,\ - org.eclipse.emf.common_2.6.0.jar; lib:=true,\ - org.eclipse.emf.ecore_2.6.1.jar; lib:=true,\ - org.eclipse.emf.ecore.xmi_2.5.0.jar; lib:=true,\ - org.eclipse.emf.edit_2.6.0.jar; lib:=true,\ - log4j-1.2-api-2.17.1.jar; lib:=true diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/build.gradle b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/build.gradle deleted file mode 100644 index d0794c91f..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -plugins { - id 'galasa.manager' -} - -description = 'Galasa Internal SEM Manager' - -version = '0.36.0' - -dependencies { - implementation files('jars/sem.jar') - implementation files('jars/org.eclipse.emf.common_2.6.0.jar') - implementation files('jars/org.eclipse.emf.ecore_2.6.1.jar') - implementation files('jars/org.eclipse.emf.ecore.xmi_2.5.0.jar') - implementation files('jars/org.eclipse.emf.edit_2.6.0.jar') - - implementation project(':galasa-managers-cicsts-parent:dev.galasa.cicsts.manager') - implementation project(':galasa-managers-core-parent:dev.galasa.artifact.manager') - implementation project(':galasa-managers-comms-parent:dev.galasa.http.manager') - - implementation 'org.apache.velocity:velocity-engine-core:2.3' - implementation 'org.apache.logging.log4j:log4j-1.2-api:2.17.1' -} - -// Note: These values are consumed by the parent build process -// They indicate which packages of functionality this OSGi bundle should be delivered inside, -// or referenced from. -// The settings here are gathered together by the build process to create a release.yaml file -// which gathers-up all the packaging metadata about all the OSGi bundles in this component. -ext.projectName=project.name -ext.includeInOBR = true -ext.includeInMVP = false -ext.includeInBOM = true -ext.includeInIsolated = false -ext.includeInCodeCoverage = false -ext.includeInJavadoc = false \ No newline at end of file diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.common_2.6.0.jar b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.common_2.6.0.jar deleted file mode 100644 index e3317d5fe..000000000 Binary files a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.common_2.6.0.jar and /dev/null differ diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.ecore.xmi_2.5.0.jar b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.ecore.xmi_2.5.0.jar deleted file mode 100644 index bd8848bbc..000000000 Binary files a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.ecore.xmi_2.5.0.jar and /dev/null differ diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.ecore_2.6.1.jar b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.ecore_2.6.1.jar deleted file mode 100644 index ddf761b76..000000000 Binary files a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.ecore_2.6.1.jar and /dev/null differ diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.edit_2.6.0.jar b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.edit_2.6.0.jar deleted file mode 100644 index c2e08df30..000000000 Binary files a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/org.eclipse.emf.edit_2.6.0.jar and /dev/null differ diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/sem.jar b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/sem.jar deleted file mode 100644 index 054db13fe..000000000 Binary files a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/jars/sem.jar and /dev/null differ diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/settings.gradle b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/settings.gradle deleted file mode 100644 index 16161a0ed..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'dev.galasa.sem.manager' \ No newline at end of file diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/CSDInput.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/CSDInput.java deleted file mode 100644 index 1086e16d6..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/CSDInput.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface CSDInput { - - public String file(); - public String cicsTag() default ""; - public String group() default ""; - public boolean startup() default true; - public boolean continueLines() default false; - public String minimumRelease() default ""; - public String maximumRelease() default ""; -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/CSDInputs.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/CSDInputs.java deleted file mode 100644 index d4fcff80c..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/CSDInputs.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface CSDInputs { - - public CSDInput[] value(); -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/DoNotBuild.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/DoNotBuild.java deleted file mode 100644 index aa80fe201..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/DoNotBuild.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Requests that SEM does not build the Complex, used if the test wants to - * build the CICS Regions itself - * - * - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -public @interface DoNotBuild { - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/DoNotStartCICS.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/DoNotStartCICS.java deleted file mode 100644 index 457809f7c..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/DoNotStartCICS.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation will inform the provisioning system (SEM) - * not to start any CICS regions. - * - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface DoNotStartCICS { - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemManagerException.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemManagerException.java deleted file mode 100644 index 202f8ea66..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemManagerException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import dev.galasa.cicsts.CicstsManagerException; - -public class SemManagerException extends CicstsManagerException { - private static final long serialVersionUID = 1L; - - public SemManagerException() { - } - - public SemManagerException(String message) { - super(message); - } - - public SemManagerException(Throwable cause) { - super(cause); - } - - public SemManagerException(String message, Throwable cause) { - super(message, cause); - } - - public SemManagerException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemManagerField.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemManagerField.java deleted file mode 100644 index f1290f7b5..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemManagerField.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Used to annotate annotations that are to be used for Test Class fields. To be - * populated by the Manager. - * - * - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -public @interface SemManagerField { - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemTopology.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemTopology.java deleted file mode 100644 index eb60d7492..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/SemTopology.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Represents a SEM topology to build a set of CICS regions from - * - * - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -@SemManagerField -public @interface SemTopology { - - /** - * The name of the SEM Model to use to build the CICS Regions - */ - String model() default "SingleRegion"; - - /** - * Which image tag will be used by default for building the CICS complex - */ - String imageTag() default "PRIMARY"; - - /** - * If required, what the secondary image tag is for building the CICS complex - */ - String secondaryImageTag() default ""; -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/Sit.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/Sit.java deleted file mode 100644 index 8f33ce024..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/Sit.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * This annotation allows the user to set a single SIT parm to be used by one - * or all the regions in their SEM environment. - * - * To set multiple SITs see {@link @Sits}. - *

- * Usage: - *
- * {@link @Sit}(parameter="SITPARM1",value="1",cicsTag="A")
- * or
- * {@link @Sit}(parameter="SITPARM2",value="TWO")
- *

- * - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface Sit { - - public String cicsTag() default "UNTAGGED"; - public String parameter(); - public String value(); - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/Sits.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/Sits.java deleted file mode 100644 index 5c3c74b4c..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/Sits.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * This annotation will allow the tester to provide multiple {@link @Sit} annotations. - *

- * Usage: - *
- * {@link @Sits}({
- * {@link @Sit}(parameter="SITPARM1",value="1",tag="A"),
- * {@link @Sit}(parameter="SITPARM2",value="TWO")
- * }) - *

- * - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface Sits { - - public Sit[] value(); -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/CsdInputGenerator.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/CsdInputGenerator.java deleted file mode 100644 index 99f3aa25e..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/CsdInputGenerator.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.io.StringWriter; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; - -import dev.galasa.artifact.IArtifactManager; -import dev.galasa.artifact.IBundleResources; -import dev.galasa.sem.CSDInput; -import dev.galasa.sem.CSDInputs; -import dev.galasa.sem.SemManagerException; -import sem.Environment; -import sem.SemFactory; - -public class CsdInputGenerator { - - private static final Log logger = LogFactory.getLog(CsdInputGenerator.class); - private final SemManagerImpl semManager; - - public CsdInputGenerator(SemManagerImpl semManager) { - this.semManager = semManager; - } - - public void generate(Environment environment, Class testClass) throws SemManagerException { - CSDInputs csdInputs = testClass.getAnnotation(CSDInputs.class); - if (csdInputs != null) { - processCsdInputs(environment, csdInputs, testClass); - } - - CSDInput csdInput = testClass.getAnnotation(CSDInput.class); - if (csdInput != null) { - processCsdInput(environment, csdInput, testClass); - } - } - - private void processCsdInputs(Environment environment, CSDInputs csdInputs, Class testClass) throws SemManagerException { - if (csdInputs.value() == null) { - return; - } - - for(CSDInput csdInput : csdInputs.value()) { - processCsdInput(environment, csdInput, testClass); - } - - } - - private void processCsdInput(Environment environment, CSDInput csdInput, Class testClass) throws SemManagerException { - String inputName = csdInput.file().trim(); - String groupName = csdInput.group().trim(); - String[] tags = csdInput.cicsTag().split(","); - boolean startup = csdInput.startup(); - String minVersion = csdInput.minimumRelease(); - String maxVersion = csdInput.maximumRelease(); - - IArtifactManager artifactManager = this.semManager.getArtifactManager(); - IBundleResources bundleResources = artifactManager.getBundleResources(testClass); - - for (String tag : tags) { - - tag = tag.trim().toUpperCase(); - - // Map complexProperties = teamManager.getCicsComplexProperties(); - // Not sure why we need this, but leaving the code commented as a reminder - - VelocityContext substitutions = new VelocityContext(); - //for(Entry entry : complexProperties.entrySet()) { - // substitutions.put(entry.getKey(), entry.getValue()); - // } - - StringWriter writer = new StringWriter(); - try { - InputStream stream = bundleResources.retrieveFile(inputName + ".csdinput"); - InputStreamReader reader = new InputStreamReader(stream); - Velocity.evaluate(substitutions, writer, "CSDInputVelocity", reader); - } catch(Exception e) { - throw new SemManagerException("Unable to read CSDInput artifact '" + inputName + "'", e); - } - - - inputName = inputName.replaceAll(".*/", ""); - - - - //*** Check that no lines exceed 71 chars - StringBuilder sb = new StringBuilder(); - try { - BufferedReader br = new BufferedReader(new StringReader(writer.toString())); - String line = null; - int lineno = 0; - while((line = br.readLine()) != null) { - lineno++; - if (line.isEmpty()) { - sb.append("\n"); - continue; - } - - if (line.charAt(0) == '*') { - sb.append(line); - sb.append("\n"); - continue; - } - - if (line.length() < 72) { - sb.append(line); - sb.append("\n"); - continue; - } - - if (line.contains("&")) { // Let SEM deal with it - sb.append(line); - sb.append("\n"); - continue; - } - - if (line.charAt(71) == '*' || line.charAt(71) == 'X') { - sb.append(line); - sb.append("\n"); - continue; - } - - String remainder = line.substring(71).trim(); - if (remainder.isEmpty()) { - sb.append(line); - sb.append("\n"); - continue; - } - - if (!csdInput.continueLines()) { - throw new SemManagerException("Line " + lineno + " in CSDInput artifact '" + inputName + "' exceeds 72 bytes"); - } - - String firstline = line.substring(0, 71); - String secondline = line.substring(71); - - sb.append(firstline); - sb.append("*\n"); - sb.append(secondline); - sb.append("\n"); - - logger.warn("Line " + lineno + " in CSDInput artifact '" + inputName + "' has been continued on a new line"); - } - - br.close(); - } catch(SemManagerException e) { - throw e; - } catch(Exception e) { - throw new SemManagerException("Problem checking for continuations in CSDInput artifact '" + inputName + "'", e); - } - - - - - sem.CSDInput semCSDInput = SemFactory.eINSTANCE.createCSDInput(); - semCSDInput.setName("Artifact " + inputName); - - - StringBuilder condition = new StringBuilder(); - - - if (tag.length() > 0) { - if (condition.length() > 0) { - condition.append(" AND "); - } - condition.append("&TAG(" + tag.toUpperCase() + ") = 'YES'"); - } - - - if (!minVersion.isEmpty()) { - if (condition.length() > 0) { - condition.append(" AND "); - } - condition.append("&CICSVERSION >= '" + minVersion + "'"); - } - - if (!maxVersion.isEmpty()) { - if (condition.length() > 0) { - condition.append(" AND "); - } - condition.append("&CICSVERSION <= '" + maxVersion + "'"); - } - - - - if (condition.length() > 0) { - semCSDInput.setCondition(condition.toString()); - } - - - if (startup) { - if (groupName.length() > 0) { - semCSDInput.setGroup(groupName.toUpperCase()); - } else { - String filename = inputName.replaceAll("(\\\\|\\/)", "\\" + System.getProperty("file.separator")); - File file = new File(filename); - String name = file.getName().toUpperCase(); - semCSDInput.setGroup(name); - } - } - - semCSDInput.setInput(sb.toString()); - - semCSDInput.setApplyonce(true); - semCSDInput.setAllowAddGroup(true); - - environment.getCSDINPUTS().add(semCSDInput); - } - - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemCicsImpl.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemCicsImpl.java deleted file mode 100644 index c1935df28..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemCicsImpl.java +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; - -import javax.validation.constraints.NotNull; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.ibm.hursley.cicsts.test.sem.complex.CICSRegion; -import com.ibm.hursley.cicsts.test.sem.complex.Complex; -import com.ibm.hursley.cicsts.test.sem.complex.Sit; -import com.ibm.hursley.cicsts.test.sem.complex.jcl.Job; - -import conrep.CICS; -import dev.galasa.ManagerException; -import dev.galasa.ProductVersion; -import dev.galasa.cicsts.CicstsManagerException; -import dev.galasa.cicsts.ICicsRegion; -import dev.galasa.cicsts.MasType; -import dev.galasa.cicsts.spi.BaseCicsImpl; -import dev.galasa.cicsts.spi.ICicstsManagerSpi; -import dev.galasa.sem.SemManagerException; -import dev.galasa.sem.internal.properties.ExternalVersion; -import dev.galasa.zos.IZosImage; -import dev.galasa.zosbatch.IZosBatch; -import dev.galasa.zosbatch.IZosBatchJob; -import dev.galasa.zosbatch.IZosBatchJob.JobStatus; -import dev.galasa.zosbatch.IZosBatchJobOutputSpoolFile; -import dev.galasa.zosbatch.IZosBatchJobname; -import dev.galasa.zosbatch.ZosBatchException; -import dev.galasa.zosconsole.IZosConsole; -import dev.galasa.zosconsole.ZosConsoleException; -import dev.galasa.zosconsole.ZosConsoleManagerException; - -public class SemCicsImpl extends BaseCicsImpl { - - private static final Log logger = LogFactory.getLog(SemCicsImpl.class); - - private final SemManagerImpl semManager; - private final SemZosHandler semZosHandler; - - private final Complex complex; - private final CICS conrepCics; - private CICSRegion complexCics; - - private String jcl; - private final String jobname; - private final String vtamnode; - private final boolean provisionStart; - - private IZosBatchJob job; - - private ProductVersion productVersion; - - public SemCicsImpl(SemManagerImpl semManager, ICicstsManagerSpi cicstsManager, SemZosHandler semZosHandler, Complex complex, CICS conrepCics, IZosImage zosImage, String cicsTag, MasType masType, boolean provisionStart) throws CicstsManagerException { - super(cicstsManager, cicsTag, zosImage, conrepCics.getApplid().getApplid(), masType); - this.semManager = semManager; - this.semZosHandler = semZosHandler; - this.conrepCics = conrepCics; - this.complex = complex; - this.provisionStart = provisionStart; - - try { - this.productVersion = ExternalVersion.get(this.conrepCics.getCICSVersion().getVersion().getLiteral().substring(1)); - } catch (ManagerException e) { - throw new SemManagerException("Unable to parse the CICS TS version", e); - } - - for(CICSRegion cicsRegion : complex.getCICS()) { - if (cicsRegion.getApplid().equals(getApplid())) { - this.complexCics = cicsRegion; - break; - } - } - - if (this.complexCics == null) { - throw new SemManagerException("Unable to locate CICS Region in SEM complex with applid '" + getApplid() + "'"); - } - - // Get a runtime job for this CICS - ArrayList jobs = new ArrayList<>(); - - try { - this.complexCics.Build_Runtime_Jobs(this.complex, jobs); - - } catch (Exception e) { - throw new SemManagerException("Could not generate the CICS runtime JCL", e); - } - - // Only one job should found - if (jobs.size() != 1) { - throw new SemManagerException("More than one runtime JCL returned from complex"); - } - - // Get the single job in the array - Job job = jobs.get(0); - - // Set the constant information of this CICS job - this.jobname = job.getJobname(); - this.vtamnode = this.complexCics.getVtamnode(); - - // Build JCL to startup CICS - buildCicsJcl(job); - } - - /** - * From a batch job, generate some JCL to startup CICS - * and activate the APPLID of the CICS job. Store the JCL - * ready for CICS startup. - * - * @param job - * @throws SemManagerException - */ - private void buildCicsJcl(Job job) throws SemManagerException { - - try { - - // Generate the JCL from the job - String runtimeJcl = semZosHandler.generateJCL(job); - - StringBuilder sb = new StringBuilder(); - - // Append the start of the JCL with system information - sb.append("/*JOBPARM SYSAFF="); - sb.append(getZosImage().getSysname()); - sb.append("\n"); - - // Append the JCL with commands to initialise the APPLID - if (this.vtamnode != null && vtamnode.length() > 0) { - sb.append("//NET COMMAND 'VARY NET,ID="); - sb.append(this.vtamnode); - sb.append(",ACT'\n"); - } - - // Append the runtime CICS JCL to existing JCL - sb.append(runtimeJcl); - - // Store the JCL ready for runtime - this.jcl = sb.toString(); - - } catch (Exception e) { - - throw new SemManagerException("Unable to generate CICS region JCL", e); - } - } - - @Override - public ProductVersion getVersion() throws CicstsManagerException { - return this.productVersion; - } - - protected CICSRegion getComplexCics() { - return this.complexCics; - } - - protected CICS getConrepCics() { - return this.conrepCics; - } - - protected String getJCL() { - return this.jcl; - } - - protected String getJobname() { - return this.jobname; - } - - @Override - public boolean isProvisionStart() { - return this.provisionStart; - } - - @Override - public void startup() throws SemManagerException { - submitRuntimeJcl(); - - Instant expire = Instant.now().plus(1, ChronoUnit.MINUTES); - while(expire.isAfter(Instant.now())) { - if (hasRegionStarted()) { - try { - this.semManager.getCicsManager().cicstsRegionStarted(this); - } catch (CicstsManagerException e) { - throw new SemManagerException("Post startup for CICS TS region " + getApplid() + " failed", e); - } - return; - } - } - - throw new SemManagerException("Provisioned CICS TS Region " + getApplid() + " failed to start in time"); - } - - @Override - public void shutdown() throws SemManagerException { - logger.info("Shutting down CICS TS region " + getApplid()); - if (this.job == null) { - logger.info("Not shutting down CICS TS Region " + getApplid() + " as it is not up"); - return; - } - - JobStatus currentStatus = job.getStatus(); - switch(currentStatus) { - case ACTIVE: - issueShutdownCommand(false); - break; - case INPUT: - logger.warn("CICS TS region is on input queue, cancelling"); - try { - this.job.cancel(); - } catch (ZosBatchException e) { - throw new SemManagerException("Unable to cancel the CICS TS region from the JES2 input queue", e); - } - saveCicsRegion(); - return; - case NOTFOUND: - logger.warn("Unable to locate CICS TS region, shutdown bypassed"); - return; - case OUTPUT: - logger.info("CICS TS region already down"); - saveCicsRegion(); - return; - case UNKNOWN: - throw new SemManagerException("Unable to determine status of the CICS TS region"); - } - - logger.info("Waiting for provisioned CICS TS region " + getApplid() + " to shutdown"); - - if (waitForRegionsToStop(2)) { - return; - } - - logger.info("CICS TS region " + getApplid() + " did not stop within 2 minutes, trying immediate shutdown"); - - issueShutdownCommand(true); - - if (waitForRegionsToStop(2)) { - return; - } - - logger.info("CICS TS region " + getApplid() + " did not stop within 2 minutes, trying cancel"); - - try { - this.job.cancel(); - } catch (ZosBatchException e) { - throw new SemManagerException("Cancel for CICS TS region failed", e); - } - - if (waitForRegionsToStop(2)) { - return; - } - - throw new SemManagerException("CICS TS region " + getApplid() + " failed to shutdown"); - } - - private boolean waitForRegionsToStop(int timeoutMinutes) throws SemManagerException { - - Instant expire = Instant.now().plus(timeoutMinutes, ChronoUnit.MINUTES); - while(expire.isAfter(Instant.now())) { - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new SemManagerException("Wait for CICS TS region stop interrupted", e); - } - - JobStatus currentStatus = job.getStatus(); - switch(currentStatus) { - case ACTIVE: - break; - case OUTPUT: - logger.info("CICS TS region has been shutdown"); - saveCicsRegion(); - return true; - default: - throw new SemManagerException("Invalid status during CICS TS region shutdown, " + currentStatus.toString()); - } - } - - return false; - } - - private void issueShutdownCommand(boolean immediate) throws SemManagerException { - if (job == null) { - throw new SemManagerException("Unable to determine the batch job for CICS TS Region " + getApplid()); - } - - IZosConsole console; - try { - console = this.semManager.getZosConsoleManager().getZosConsole(getZosImage()); - } catch (ZosConsoleManagerException e) { - throw new SemManagerException("Unable to obtain console for shutdown command", e); - } - - switch(getMasType()) { - case CICS: - case LMAS: - case WUI: - case NONE: - StringBuilder shutDownCommand = new StringBuilder("CEMT PERFORM SHUTDOWN"); - - if (immediate) { - shutDownCommand.append(" IMMEDIATE"); - } - - try { - console.issueCommand("F " + job.getJobname() + "," + shutDownCommand.toString()); - } catch (ZosConsoleException e) { - throw new SemManagerException("Error attempting to issue shutdown command", e); - } - logger.info("Issued '" + shutDownCommand + "' to CICS Region '" + job + "'"); - break; - case CMAS: - try { - console.issueCommand("F " + job.getJobname() + ",COSD"); - } catch (ZosConsoleException e) { - throw new SemManagerException("Error attempting to issue shutdown command", e); - } - logger.info("Issued 'COSD' to CICS TS region " + getApplid()); - return; - } - } - - - private void saveCicsRegion() { - - try { - job.saveOutputToResultsArchive("sem/cics"); - } catch (ZosBatchException e) { - logger.error("Failed to save cics output to stored artifacts", e); - } - - } - - @Override - public void submitRuntimeJcl() throws SemManagerException { - IZosBatch zosBatch = this.semManager.getZosBatch().getZosBatch(this.getZosImage()); - try { - IZosBatchJobname jobname = this.semManager.getZosManager().newZosBatchJobname(getJobname()); - // TODO need to sort the full jobcard, ie userid etc - this.job = zosBatch.submitJob(this.jcl, jobname); - this.job.setShouldArchive(false); - } catch(Exception e) { - throw new SemManagerException("Failed to submit the runtime JCL for provisioned CICS TS region " + getApplid(), e); - } - - logger.info("Submitted provisioned CICS TS region " + getApplid() + " as " + this.job); - - Instant expire = Instant.now().plus(1, ChronoUnit.MINUTES); - while(expire.isAfter(Instant.now())) { - try { - Thread.sleep(2000); - - switch(this.job.getStatus()) { - case ACTIVE: - logger.trace("Wait for region submission completed, job now active"); - return; - case INPUT: - case NOTFOUND: - break; - case OUTPUT: - throw new SemManagerException("Wait for region submission failed, job was on output queue"); - case UNKNOWN: - default: - throw new SemManagerException("Wait for region submission failed, status unknown"); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new SemManagerException("Wait for region submission was interrupted", e); - } - } - - throw new SemManagerException("Wait for provisioned CICS TS region submission failed, job did not start"); - } - - @Override - public boolean hasRegionStarted() throws SemManagerException { - - IZosBatchJobOutputSpoolFile jesmsglgSpool; - IZosBatchJobOutputSpoolFile eyulogSpool = null; - try { - jesmsglgSpool = this.job.getSpoolFile("JESMSGLG"); - if (getMasType() == MasType.WUI) { - eyulogSpool = this.job.getSpoolFile("EYULOG"); - } - } catch(Exception e) { - throw new SemManagerException("Failed to retrieve job output during region startup", e); - } - - String jesmsglg = jesmsglgSpool.getRecords(); - if (jesmsglg.contains("DFHKE0101")) { - throw new SemManagerException("Startup of CICS TS region " + getApplid() + " failed, not APF authorised"); - } - - if (jesmsglg.contains("DFHSI1538D")) { - throw new SemManagerException( - "Startup of CICS TS region " + getApplid() + " failed, invalid CSD group"); - } - - if (jesmsglg.contains("DFHPA1909") || jesmsglg.contains("DFHPA1912") || jesmsglg.contains("DFHPA1915")) { - throw new SemManagerException( - "Startup of CICS TS region " + getApplid() + " failed, invalid parameter found"); - } - - if (jesmsglg.contains("IEF404I")) { - throw new SemManagerException("Startup of CICS TS region " + getApplid() + " failed, early termination"); - } - - if (jesmsglg.contains("$HASP395")) { - throw new SemManagerException("Startup of CICS TS region " + getApplid() + " failed, early termination"); - } - - if (getMasType() == MasType.WUI) { - String eyulog = eyulogSpool.getRecords(); - - if (eyulog.contains("EYUVS0005S")) { - throw new SemManagerException("Startup of WUI region " + getApplid() + " failed, EYUVS0005S detected"); - } - - boolean DFHSI1517 = jesmsglg.contains("DFHSI1517"); - - // if (wuiBasicStartup) { - // if (DFHSI1517) { - // logger.info("WUI Region '" + job + "' has completed startup(basic)"); - // toBeCheckedi.remove(); - // checkDefaultSecurity(output); - // } - // } else { - boolean EYUVS0002I = eyulog.contains("EYUVS0002I"); - boolean EYUNL0099I = jesmsglg.contains("EYUNL0099I"); - - if (DFHSI1517 && EYUVS0002I && EYUNL0099I) { - logger.info("WUI Region " + getApplid() + " has completed startup"); - // checkDefaultSecurity(output); - return true; - } - // } - } else if (getMasType() == MasType.CMAS) { - boolean DFHSI1517 = jesmsglg.contains("DFHSI1517"); - - // if (cmasBasicStartup) { - // if (DFHSI1517) { - // logger.info("CMAS Region '" + job + "' has completed startup(basic)"); - // toBeCheckedi.remove(); - // checkDefaultSecurity(output); - // } - // } else { - boolean EYUXL0010I = jesmsglg.contains("EYUXL0010I"); - - if (DFHSI1517 && EYUXL0010I) { - logger.info("CMAS Region " + getApplid() + " has completed startup"); - // checkDefaultSecurity(output); - return true; - } - } else { - if (jesmsglg.contains("DFHSI1517")) { - logger.info("CICS TS Region " + getApplid() + " has completed startup"); - // checkDefaultSecurity(output); - return true; - } - } - - return false; - } - - @Override - public String getUssHome() throws CicstsManagerException { - throw new CicstsManagerException("Not developed yet"); - } - - @Override - public String getJvmProfileDir() throws CicstsManagerException { - throw new CicstsManagerException("Not developed yet"); - } - - @Override - public String getJavaHome() throws CicstsManagerException { - throw new CicstsManagerException("Not developed yet"); - } - - @Override - public IZosBatchJob getRegionJob() throws CicstsManagerException { - if (this.job == null) { - throw new CicstsManagerException("The CICS Region job for the CICS TS region is missing"); - } - - return this.job; - } - - @Override - public void alterSit(@NotNull String sitParam, String sitValue) throws CicstsManagerException { - - // Get the CICS - ICicsRegion theCics = cicstsManager.locateCicsRegion(this.getTag()); - - // Restricted SIT parameter - if (sitParam.toUpperCase().equals("APPLID") | sitParam.toUpperCase().equals("GRPLIST") || sitParam.toUpperCase().equals("SYSID")) { - throw new CicstsManagerException(sitParam.toUpperCase() + " is a restricted SIT parameter. It cannot be changed"); - } - - // CICS is currently running - if (job.getStatus() == JobStatus.ACTIVE) { - throw new CicstsManagerException("The CICS region " + theCics.getApplid() + " with tag " + theCics.getTag() + " is still running. Cannot alter a running CICS region"); - } - - for (CICSRegion cicsRegion : complex.getCICS()) { - - // Find the correct region - if (cicsRegion.getApplid().equals(theCics.getApplid())) { - - // Add the Sit parameter - if (sitValue != null) { - - Sit sitOverride = new Sit(sitParam, sitValue, "Overridden during runtime"); - - // Apply the SIT override - cicsRegion.runtimeOverrideSIT(sitOverride); - rebuildRuntimeJob(cicsRegion); - - } else { - - throw new CicstsManagerException("Sit value in alterSit() cannot be null use removeSit()"); - } - } - } - } - - @Override - public void removeSit(@NotNull String sitParam) throws CicstsManagerException { - - // Get the CICS - ICicsRegion theCics = cicstsManager.locateCicsRegion(this.getTag()); - - // Check the restricted parameters - if (sitParam.toUpperCase().equals("APPLID") | sitParam.toUpperCase().equals("GRPLIST") || sitParam.toUpperCase().equals("SYSID")) { - throw new CicstsManagerException(sitParam.toUpperCase() + " is a restricted SIT parameter. It cannot be removed"); - } - - // Check if CICS is currently running - if (job.getStatus() == JobStatus.ACTIVE) { - throw new CicstsManagerException("The CICS region " + theCics.getApplid() + " with tag " + theCics.getTag() + " is still running. Cannot remove a SIT from a running region"); - } - - for (CICSRegion cicsRegion : complex.getCICS()) { - - // Find the correct region - if (cicsRegion.getApplid().equals(theCics.getApplid())) { - - // Remove the SIT - cicsRegion.removeSit(sitParam); - rebuildRuntimeJob(cicsRegion); - } - } - } - - /** - * Performs a rebuild of the given CICS job - * - * @param region - * @throws CicstsManagerException - */ - private void rebuildRuntimeJob(CICSRegion region) throws CicstsManagerException { - - ArrayList jobs = new ArrayList(); - - try { - - // Rebuild the JCL with the changed SIT parameter - region.Build_Runtime_Jobs(complex, jobs); - - } catch (Exception e) { - throw new CicstsManagerException("Unable to rebuild runtime JCL" , e); - } - - // Perform a rebuild of the JCL - buildCicsJcl(jobs.get(0)); - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemManagerImpl.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemManagerImpl.java deleted file mode 100644 index 820d4709d..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemManagerImpl.java +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.lang.annotation.Annotation; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; -import java.util.UUID; - -import javax.validation.constraints.NotNull; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.LogManager; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; -import org.osgi.service.component.annotations.Component; - -import com.ibm.hursley.cicsts.test.sem.complex.Complex; -import com.ibm.hursley.cicsts.test.sem.complex.RunOptions; -import com.ibm.hursley.cicsts.test.sem.complex.jcl.JCLException; -import com.ibm.hursley.cicsts.test.sem.complex.jcl.Job; - -import conrep.CICS; -import conrep.ConRep; -import conrep.MVS; -import conrep.impl.ConrepPackageImpl; -import dev.galasa.ManagerException; -import dev.galasa.ProductVersion; -import dev.galasa.artifact.IArtifactManager; -import dev.galasa.artifact.IBundleResources; -import dev.galasa.artifact.TestBundleResourceException; -import dev.galasa.cicsts.CicstsManagerException; -import dev.galasa.cicsts.ICicsRegion; -import dev.galasa.cicsts.MasType; -import dev.galasa.cicsts.spi.ICicsRegionProvisioned; -import dev.galasa.cicsts.spi.ICicsRegionProvisioner; -import dev.galasa.cicsts.spi.ICicstsManagerSpi; -import dev.galasa.framework.spi.AbstractManager; -import dev.galasa.framework.spi.ConfigurationPropertyStoreException; -import dev.galasa.framework.spi.DynamicStatusStoreException; -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IFramework; -import dev.galasa.framework.spi.IManager; -import dev.galasa.framework.spi.ResourceUnavailableException; -import dev.galasa.framework.spi.creds.CredentialsUsernamePassword; -import dev.galasa.framework.spi.language.GalasaTest; -import dev.galasa.http.HttpClientException; -import dev.galasa.http.HttpClientResponse; -import dev.galasa.http.IHttpClient; -import dev.galasa.http.spi.IHttpManagerSpi; -import dev.galasa.sem.DoNotBuild; -import dev.galasa.sem.DoNotStartCICS; -import dev.galasa.sem.SemManagerException; -import dev.galasa.sem.SemTopology; -import dev.galasa.sem.internal.properties.BaseModel; -import dev.galasa.sem.internal.properties.CicsBuild; -import dev.galasa.sem.internal.properties.InteralVersion; -import dev.galasa.sem.internal.properties.ModelUrl; -import dev.galasa.sem.internal.properties.SemPropertiesSingleton; -import dev.galasa.zos.IZosImage; -import dev.galasa.zos.spi.IZosManagerSpi; -import dev.galasa.zosbatch.IZosBatch; -import dev.galasa.zosbatch.IZosBatchJob; -import dev.galasa.zosbatch.IZosBatchJob.JobStatus; -import dev.galasa.zosbatch.ZosBatchException; -import dev.galasa.zosbatch.spi.IZosBatchSpi; -import dev.galasa.zosconsole.spi.IZosConsoleSpi; -import sem.DEFCICS; -import sem.Environment; -import sem.SemFactory; -import sem.SymGroup; -import sem.Symbolic; -import sem.impl.SemPackageImpl; - -@Component(service = { IManager.class }) -public class SemManagerImpl extends AbstractManager implements ICicsRegionProvisioner { - protected static final String NAMESPACE = "sem"; - - private static final Log logger = LogFactory.getLog(SemManagerImpl.class); - private boolean required; - - private IDynamicStatusStoreService dss; - - private IZosManagerSpi zosManager; - private IZosBatchSpi zosBatch; - private IZosConsoleSpi zosConsole; - private ICicstsManagerSpi cicsManager; - private IArtifactManager artifactManager; - private IHttpManagerSpi httpManager; - - private SemTopology semTopology; - - private ArrayList environments = new ArrayList<>(); - - private Complex complex = new Complex(); - private SemPoolResolver poolResovler; - private final CsdInputGenerator csdGenerator = new CsdInputGenerator(this); - private final SitGenerator sitGenerator = new SitGenerator(this); - - private ConRep conrep; - - private HashMap taggedRegions = new HashMap<>(); - private HashMap applidRegions = new HashMap<>(); - - private IBundleResources semBundleResources; - private IHttpClient httpClient; - - private GalasaTest galasaTest; - - private HashMap> runtimeJobs; - private List discardJobs; - private List buildJobs; - private SemZosHandler semZosHandler; - - private IZosImage primaryZosImage; - private IZosImage secondaryZosImage; - - private final HashMap runningJobs = new HashMap<>(); - - private String consoleName; // TODO the zos console manager should be generating random names - - private boolean doNotBuild = false; - private boolean doNotStart = false; - - @Override - public void initialise(@NotNull IFramework framework, @NotNull List allManagers, - @NotNull List activeManagers, @NotNull GalasaTest galasaTest) throws ManagerException { - super.initialise(framework, allManagers, activeManagers, galasaTest); - - if (!required) { - if(galasaTest.isJava()) { - Class testClass = galasaTest.getJavaTestClass(); - - this.semTopology = testClass.getAnnotation(SemTopology.class); - if (this.semTopology == null) { - return; // Not required - } - } else { - return; // Dont support anything other than Java at the moment - } - } - - this.galasaTest = galasaTest; - - youAreRequired(allManagers, activeManagers, galasaTest); - - try { - SemPropertiesSingleton.setCps(framework.getConfigurationPropertyService(NAMESPACE)); - this.dss = getFramework().getDynamicStatusStoreService(NAMESPACE); - } catch (ConfigurationPropertyStoreException | DynamicStatusStoreException e) { - throw new CicstsManagerException("Unable to request framework services", e); - } - - semBundleResources = this.artifactManager.getBundleResources(getClass()); - } - - @Override - public void youAreRequired(@NotNull List allManagers, @NotNull List activeManagers, GalasaTest galasaTest) - throws ManagerException { - super.youAreRequired(allManagers, activeManagers, galasaTest); - - if (activeManagers.contains(this)) { - return; - } - - this.required = true; - activeManagers.add(this); - - this.zosManager = addDependentManager(allManagers, activeManagers, galasaTest, IZosManagerSpi.class); - if (this.zosManager == null) { - throw new SemManagerException("Unable to locate the zOS Manager, required for the SEM Manager"); - } - - this.zosBatch = addDependentManager(allManagers, activeManagers, galasaTest, IZosBatchSpi.class); - if (this.zosBatch == null) { - throw new SemManagerException("Unable to locate the zOS Batch Manager, required for the SEM Manager"); - } - - this.zosConsole = addDependentManager(allManagers, activeManagers, galasaTest, IZosConsoleSpi.class); - if (this.zosConsole == null) { - throw new SemManagerException("Unable to locate the zOS Console Manager, required for the SEM Manager"); - } - - this.cicsManager = addDependentManager(allManagers, activeManagers, galasaTest, ICicstsManagerSpi.class); - if (this.cicsManager == null) { - throw new SemManagerException("Unable to locate the CICS TS Manager, required for the SEM Manager"); - } - - this.artifactManager = addDependentManager(allManagers, activeManagers, galasaTest, IArtifactManager.class); - if (this.artifactManager == null) { - throw new SemManagerException("Unable to locate the Artifact Manager, required for the SEM Manager"); - } - - this.httpManager = addDependentManager(allManagers, activeManagers, galasaTest, IHttpManagerSpi.class); - if (this.httpManager == null) { - throw new SemManagerException("Unable to locate the Http Manager, required for the SEM Manager"); - } - - // Register this as a provisioner - this.cicsManager.registerProvisioner(this); - - this.consoleName = "GAL" + getFramework().getTestRunName(); - } - - @Override - public boolean areYouProvisionalDependentOn(@NotNull IManager otherManager) { - - if (otherManager == this.zosManager) { - return true; - } - - if (otherManager == this.zosBatch) { - return true; - } - - if (otherManager == this.cicsManager) { - return true; - } - - return false; - } - - @Override - public void cicsProvisionGenerate() throws ManagerException, ResourceUnavailableException { - Class testClass = this.galasaTest.getJavaTestClass(); - if (testClass.isAnnotationPresent(DoNotBuild.class)) { - this.doNotBuild = true; - this.doNotStart = true; - } - if (testClass.isAnnotationPresent(DoNotStartCICS.class)) { - this.doNotStart = true; - } - - - String provisionType = this.cicsManager.getProvisionType().toLowerCase(); - switch(provisionType) { - case "sem": - case "provisioned": - case "mixed": - break; - default: - return; - } - - if (this.semTopology == null) { - return; - } - - - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", - new XMIResourceFactoryImpl()); - SemPackageImpl.init(); - ConrepPackageImpl.init(); - - logger.info("Starting CICS TS SEM provisioning"); - - this.poolResovler = new SemPoolResolver(this); - this.complex.setPoolResolver(this.poolResovler); - - - String primaryImageTag = this.semTopology.imageTag(); - String secondaryImageTag = this.semTopology.secondaryImageTag(); - - primaryZosImage = this.zosManager.provisionImageForTag(primaryImageTag); - logger.info("Using " + primaryZosImage + " as the default system for the SEM complex"); - secondaryZosImage = null; - if (!secondaryImageTag.isEmpty()) { - secondaryZosImage = this.zosManager.getImageForTag(secondaryImageTag); - logger.info("Using " + secondaryZosImage + " as the secondary zOS Image, available via the symbolic variable &SECONDARY_SYSTEM"); - } - - ProductVersion primaryVersion = this.cicsManager.getDefaultVersion(); - String actualVersion = InteralVersion.get(primaryVersion); - logger.info("Using " + actualVersion + " as primary version for the SEM complex"); - - logger.trace("Loading SEM models"); - - logger.trace("Loading topology model"); - - fetchSemModel(semTopology.model()); - - // Add the default settings - Environment defaultEnvironment = SemFactory.eINSTANCE.createEnvironment(); - this.environments.add(defaultEnvironment); - defaultEnvironment.setDefaulttab(SemFactory.eINSTANCE.createDefaultTab()); - defaultEnvironment.setParamtab(SemFactory.eINSTANCE.createParamTab()); - - SymGroup defaultSymbolics = SemFactory.eINSTANCE.createSymGroup(); - defaultEnvironment.getParamtab().getSYMGROUPs().add(defaultSymbolics); - defaultSymbolics.setName("Galasa Symbolics"); - - DEFCICS defaultCics = SemFactory.eINSTANCE.createDEFCICS(); - defaultEnvironment.getDefaulttab().getCICSs().add(defaultCics); - defaultCics.setName("Galasa CICS Settings"); - defaultCics.setCicsversion(actualVersion); - defaultCics.setSystem(primaryZosImage.getImageID()); - - if (secondaryZosImage != null) { - Symbolic secondarySymbolic = SemFactory.eINSTANCE.createSymbolic(); - secondarySymbolic.setGROUP(defaultSymbolics); - secondarySymbolic.setName("SECONDARY_SYSTEM"); - secondarySymbolic.setValue(secondaryZosImage.getImageID()); - } - - // Set the Base versions - Symbolic baseCicsVersionSymbolic = SemFactory.eINSTANCE.createSymbolic(); - baseCicsVersionSymbolic.setGROUP(defaultSymbolics); - baseCicsVersionSymbolic.setName("BASE_CICSVERSION"); - baseCicsVersionSymbolic.setValue(actualVersion); - - Symbolic baseCpsmVersionSymbolic = SemFactory.eINSTANCE.createSymbolic(); - baseCpsmVersionSymbolic.setGROUP(defaultSymbolics); - baseCpsmVersionSymbolic.setName("BASE_CPSMVERSION"); - baseCpsmVersionSymbolic.setValue(actualVersion); - - // Set the TESTNAME, used for the datasets - Symbolic testNameSymbolic = SemFactory.eINSTANCE.createSymbolic(); - testNameSymbolic.setGROUP(defaultSymbolics); - testNameSymbolic.setName("TESTNAME"); - testNameSymbolic.setValue(getFramework().getTestRunName()); - - // Set the userid - Symbolic useridSymbolic = SemFactory.eINSTANCE.createSymbolic(); - useridSymbolic.setGROUP(defaultSymbolics); - useridSymbolic.setName("USERID"); - useridSymbolic.setValue(((CredentialsUsernamePassword)primaryZosImage.getDefaultCredentials()).getUsername()); - - // Set the HLQ - String hlq = this.zosManager.getRunDatasetHLQ(primaryZosImage); - - Symbolic hlqSymbolic = SemFactory.eINSTANCE.createSymbolic(); - hlqSymbolic.setGROUP(defaultSymbolics); - hlqSymbolic.setName("HLQ"); - hlqSymbolic.setValue(hlq); - - // Set the uss directory - String ussDirectory = this.zosManager.getRunUNIXPathPrefix(primaryZosImage); - - Symbolic ussSymbolic = SemFactory.eINSTANCE.createSymbolic(); - ussSymbolic.setGROUP(defaultSymbolics); - ussSymbolic.setName("TEMPORARY_DIRECTORY"); - ussSymbolic.setValue(ussDirectory); - - // Setup any z/OS provisioned port symbolics - for (String portTag : this.zosManager.getTaggedPorts().keySet()) { - Symbolic portSymbolic = SemFactory.eINSTANCE.createSymbolic(); - portSymbolic.setGROUP(defaultSymbolics); - portSymbolic.setName(portTag); - portSymbolic.setValue("" + this.zosManager.getTaggedPorts().get(portTag)); - } - - // Add the BUILD sem model - String cicsBuild = CicsBuild.get(); - if (cicsBuild != null) { - fetchSemModel("Version_" + actualVersion + "_Build_" + cicsBuild); - } - - // Add the Version sem model - fetchSemModel("Version_" + actualVersion); - - // Add the primary Image sem model - fetchSemModel("Plex_" + primaryZosImage.getSysplexID() + "_Image_" + primaryZosImage.getImageID()); - - // Add the primary Sysplex sem model - fetchSemModel("Plex_" + primaryZosImage.getSysplexID()); - - if (secondaryZosImage != null) { - // Add the secondary Image sem model - fetchSemModel("Plex_" + secondaryZosImage.getSysplexID() + "_Image_" + secondaryZosImage.getImageID()); - - if (!primaryZosImage.getSysplexID().equals(secondaryZosImage.getSysplexID())) { - // Add the primary Sysplex sem model if different from primary - fetchSemModel("Plex_" + secondaryZosImage.getSysplexID()); - } - } - - // Add the base model - fetchSemModel(BaseModel.get()); - - // Add the CSD Inputs to the Model - - this.csdGenerator.generate(defaultEnvironment, this.galasaTest.getJavaTestClass()); - - // Add the SITs to the Model - - this.sitGenerator.generate(defaultEnvironment, this.galasaTest.getJavaTestClass()); - - // Add the zos interfaces - - this.semZosHandler = new SemZosHandler(this.zosManager, this.zosBatch, this.primaryZosImage, this.secondaryZosImage); - - // Generate the model - generateComplex(); - - this.poolResovler.generateComplete(); - - } - - - private void generateComplex() throws SemManagerException { - try { - RunOptions options = new RunOptions(LogManager.getLoggerRepository()); - options.setBuildComplex(true); - options.setJobPurge(false); - options.setConrepRequired(false); - options.setBuildCICSplex(true); - options.setJobPrefix("GAL"); - - int rc = this.complex.buildComplex(environments, options, LogManager.getLoggerRepository()); - - if (rc > 4) { - throw new SemManagerException("SEM complex generation failed, rc=" +rc); - } - - this.conrep = this.complex.generateConRepModel(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - this.complex.reportConfig(ps); - ps.close(); - baos.close(); - - String configReport = new String(baos.toByteArray(), StandardCharsets.UTF_8); - logger.info("SEM configuration report:-\n" + configReport); - - for(CICS cics : this.conrep.getCICSs().getCICSs()) { - - // Get the TAG if there is one - String cicsTag = ""; // default just in case - if (!cics.getTag().isEmpty()) { - cicsTag = cics.getTag().get(0).getTag(); - } - - cicsTag = cicsTag.toUpperCase(); - - MVS mvs = cics.getMVS(); - if (mvs == null) { - throw new SemManagerException("SEM provisioned CICS region is missing system - '" + cics.getApplid() + "'"); - } - String jesid = mvs.getJesid(); - if (jesid == null) { - throw new SemManagerException("SEM provisioned CICS region is missing jesid - '" + cics.getApplid() + "'"); - } - - IZosImage zosImage = null; - if (this.primaryZosImage.getSysname().equals(jesid)) { - zosImage = this.primaryZosImage; - } else if (this.secondaryZosImage.getSysname().equals(jesid)) { - zosImage = this.secondaryZosImage; - } else { - throw new SemManagerException("SEM provisioned CICS region is has a jesid different to primary or secondary z/OS images - '" + cics.getApplid() + "'"); - } - - MasType masType = null; - switch(cics.getType().getType()) { - case CICS: - masType = MasType.CICS; - break; - case CMAS: - masType = MasType.CMAS; - break; - case LMAS: - masType = MasType.LMAS; - break; - case WUI: - masType = MasType.WUI; - break; - default: - throw new SemManagerException("Unrecognised CICS region type '" + cics.getType().getType() + "'"); - } - - SemCicsImpl region = new SemCicsImpl(this, this.cicsManager, this.semZosHandler, this.complex, cics, zosImage, cicsTag, masType, !this.doNotStart); - String applid = cics.getApplid().getApplid(); - this.applidRegions.put(applid, region); - - if (!cicsTag.isEmpty()) { - logger.info("Provisioned " + region + " for tag " + cicsTag); - - this.taggedRegions.put(cicsTag, region); - - if (!cics.getTag().isEmpty()) { - for(int i = 1; i < cics.getTag().size(); i++) { - String tag = cics.getTag().get(i).getTag().toUpperCase(); - this.taggedRegions.put(tag, region); - logger.info("Provisioned " + region + " for tag " + tag); - } - } - } - - this.poolResovler.getApplidPool().setSystem(applid, zosImage.getSysname()); - } - - } catch(SemManagerException e) { - throw e; - } catch(Exception e) { - throw new SemManagerException("Problem generating SEM complex", e); - } - - } - - private void fetchSemModel(@NotNull String model) throws SemManagerException { - if (!model.endsWith(".sem")) { - model += ".sem"; - } - // First, check to see if it is in the test bundle - IBundleResources testBundleResources = this.artifactManager.getBundleResources(getTestClass()); - try { - String modelString = testBundleResources.retrieveFileAsString(model); - this.environments.add(convertModel(modelString)); - logger.trace("Located SEM model '" + model + "' in test bundle"); - return; - } catch (TestBundleResourceException e) { - logger.trace("Did not find SEM model '" + model + "' in test bundle"); - // Ignore because it may not exist in the bundle - } catch (IOException e) { - throw new SemManagerException("Unable to read SEM model '" + model + "' from test bundle", e); - } - - // Now, check to see if it is in the manager bundle - try { - String modelString = semBundleResources.retrieveFileAsString(model); - this.environments.add(convertModel(modelString)); - logger.trace("Located SEM model '" + model + "' in manager bundle"); - return; - } catch (TestBundleResourceException e) { - // Ignore because it may not exist in the bundle - logger.trace("Did not find SEM model '" + model + "' in manager bundle"); - } catch (IOException e) { - throw new SemManagerException("Unable to read SEM model '" + model + "' from manager bundle", e); - } - - // Find the model from an online server - if (this.httpClient == null) { - this.httpClient = this.httpManager.newHttpClient(); - try { - this.httpClient.setURI(ModelUrl.get().toURI()); - } catch (URISyntaxException e) { - throw new SemManagerException("Badly formed URI for the sem.model.url", e); - } - } - - String modelUrl = ModelUrl.get() + "/" + model; - - try { - HttpClientResponse response = this.httpClient.getText(model); - - if (response.getStatusCode() == 200) { - this.environments.add(convertModel(response.getContent())); - logger.trace("Located SEM model '" + model + "' on website"); - return; - } else if (response.getStatusCode() == 404) { - // Ignore because it may not exist in the website - logger.trace("Did not find SEM model '" + model + "' on website"); - } else { - throw new SemManagerException("Unable to read SEM model '" + model + "' from url " + modelUrl + " - " + response.getStatusLine()); - } - } catch(HttpClientException e) { - throw new SemManagerException("Unable to read SEM model '" + model + "' from url " + modelUrl,e); - } - - throw new SemManagerException("Unable to locate the SEM model '" + model + "'"); - } - - @Override - public ICicsRegionProvisioned provision(@NotNull String cicsTag, @NotNull String imageTag, - @NotNull List annotations) throws ManagerException { - - return this.taggedRegions.get(cicsTag.toUpperCase()); - } - - @Override - public void cicsProvisionBuild() throws ManagerException, ResourceUnavailableException { - if (this.doNotBuild) { - logger.info("Ignoring build of complex as @SemDoNotBuild is present"); - return; - } - - String provisionType = this.cicsManager.getProvisionType().toLowerCase(); - switch(provisionType) { - case "sem": - case "provisioned": - case "mixed": - break; - default: - return; - } - - // TODO do we need to replicate provisioning type of Resolved? - - // TODO feature toggle support? - - try { - complex.registerFileProvider(this.semZosHandler); - complex.registerJobProvider(this.semZosHandler); - - runtimeJobs = complex.getRuntimeJobMap(complex, conrep); - discardJobs = complex.getDiscardJobs(environments); - - logger.info("Checking for running CICS Regions"); - checkForRunningJobs(); - - // add all jobs to run dynamics - - buildJobs = complex.getBuildJobs(environments); - - if (!complex.runJobs(buildJobs)) { - logger.fatal("Some build jobs failed"); - retrieveOutput("sem/buildjob/", this.semZosHandler.getJobs()); - throw new SemManagerException("Some build jobs have failed"); - } - - retrieveOutput("sem/buildjob/", this.semZosHandler.getJobs()); - - } catch (Exception e) { - if (e.getMessage().equals("got into a no running jobs state!!!")) { - retrieveOutput("sem/buildjob/", this.semZosHandler.getJobs()); - } - - throw new SemManagerException("Build of CICS complex failed", e); - } - - - } - - - - private void retrieveOutput(String path, List jobs) { - for(IZosBatchJob job : jobs) { - try { - job.saveOutputToResultsArchive(path); - } catch (ZosBatchException e) { - logger.error("Failed to archive output from " + job); - } - - try { - job.purge(); - } catch (ZosBatchException e) { - logger.warn("Failed to purge " + job); - } - } - - } - - private void checkForRunningJobs() throws SemManagerException { - boolean failedCancel = false; - - IZosBatch batch = this.zosBatch.getZosBatch(this.primaryZosImage); - - for (Entry> cicsRuntimeJobs : runtimeJobs.entrySet()) { - for (Job job : cicsRuntimeJobs.getValue()) { - try { - List possibleJobs = batch.getJobs(job.getJobname(), "*"); - for(IZosBatchJob possibleJob : possibleJobs) { - if (possibleJob.getStatus() == JobStatus.ACTIVE) { - logger.info("Cancelling pre running CICS Region '" - + possibleJob.getJobname() + "(" + possibleJob.getJobId() + ")'"); - possibleJob.cancel(); - } - } - } catch (Exception e) { - logger.error( - "Failed to cancel existing job " + job.getJobname(), - e); - failedCancel = true; - } - } - } - if (failedCancel) { - throw new SemManagerException("Failed to cancel existing jobs"); - } - - return; - } - - - @Override - public void cicsProvisionStart() throws ManagerException, ResourceUnavailableException { - if (this.doNotBuild) { - logger.info("Ignoring start of complex as @SemDoNotBuild is present"); - return; - } - if (this.doNotStart) { - logger.info("Ignoring start of complex as @DoNotStartCICS is present"); - return; - } - - ArrayList cicss = new ArrayList<>(this.applidRegions.values()); - startupCics(cicss); - } - - private void startupCics(List regions) throws SemManagerException { - ArrayList submittedRegions = new ArrayList<>(regions.size()); - for(ICicsRegion oRegion : regions) { - if (!(oRegion instanceof SemCicsImpl)) { - continue; // Ignore regions from other provisioners - } - - SemCicsImpl region = (SemCicsImpl) oRegion; - region.startup(); // TODO multithread startup and wait - submittedRegions.add(region); - } - } - - @Override - public void cicsProvisionStop() { - if (this.doNotBuild) { - logger.info("Ignoring stop of complex as @SemDoNotBuild is present"); - return; - } - - logger.info("Stopping all SEM provisioned CICS regions"); - ArrayList regions = new ArrayList<>(this.applidRegions.values()); - for(SemCicsImpl region : regions) { - try { - region.shutdown(); // TODO multithread shutdown and wait - } catch(SemManagerException e) { - logger.error("Shutdown of CICS TS region " + region.getApplid() + " failed"); - } - } - logger.info("All SEM provisioned CICS regions have stopped"); - } - - @Override - public void cicsProvisionDiscard() { - if (this.doNotBuild) { - logger.info("Ignoring discard of complex as @SemDoNotBuild is present"); - return; - } - - String provisionType = this.cicsManager.getProvisionType().toLowerCase(); - switch(provisionType) { - case "sem": - case "provisioned": - case "mixed": - break; - default: - return; - } - - logger.info("Discarding SEM complex"); - this.semZosHandler.clearJobs(); - - // Run the discard jobs - for(Job job : this.discardJobs) { - try { - this.semZosHandler.submitJob(job); - } catch (JCLException e) { - logger.error("Unable to submit discard job"); - } - } - - Instant expire = Instant.now().plus(20, ChronoUnit.MINUTES); // time out after 10 minutes - // Wait for them to complete - List waiting = this.semZosHandler.getJobs(); - ArrayList completed = new ArrayList<>(waiting.size()); - while(Instant.now().isBefore(expire)) { - Iterator jobi = waiting.iterator(); - while(jobi.hasNext()) { - IZosBatchJob job = jobi.next(); - - if (job.getStatus() == JobStatus.OUTPUT) { - completed.add(job); - jobi.remove(); - } - } - - if (waiting.isEmpty()) { - break; - } - } - - // record the output - retrieveOutput("sem/discard/", completed); - retrieveOutput("sem/discard_not_finished/", waiting); - - this.poolResovler.discard(); - - super.provisionDiscard(); - - logger.info("SEM discard is complete"); - } - - - - - - - - - public Environment convertModel(@NotNull String modelString) throws SemManagerException { - ByteArrayInputStream bais = new ByteArrayInputStream(modelString.getBytes()); - - ResourceSet resSet = new ResourceSetImpl(); - HashMap dummyOptions = new HashMap(); - - Resource resource = resSet.createResource(org.eclipse.emf.common.util.URI.createURI("sem://" + UUID.randomUUID().toString())); - try { - resource.load(bais, dummyOptions); - } catch (IOException e) { - throw new SemManagerException("Unable to load the SEM model ", e); - } - - return (Environment)resource.getContents().get(0); - } - - public IDynamicStatusStoreService getDss() { - return this.dss; - } - - protected IArtifactManager getArtifactManager() { - return this.artifactManager; - } - - protected ICicstsManagerSpi getCicsManager() { - return this.cicsManager; - } - - protected IZosManagerSpi getZosManager() { - return this.zosManager; - } - - protected IZosBatchSpi getZosBatch() { - return this.zosBatch; - } - - public IZosConsoleSpi getZosConsoleManager() { - return this.zosConsole; - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolApplids.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolApplids.java deleted file mode 100644 index 4c745866f..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolApplids.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.ibm.hursley.cicsts.test.sem.interfaces.complex.IPool; - -import dev.galasa.framework.spi.DssAdd; -import dev.galasa.framework.spi.DssDelete; -import dev.galasa.framework.spi.DssResourceDeletePrefix; -import dev.galasa.framework.spi.DssResourceUpdate; -import dev.galasa.framework.spi.DssUpdate; -import dev.galasa.framework.spi.DynamicStatusStoreException; -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IResourcePoolingService; -import dev.galasa.framework.spi.InsufficientResourcesAvailableException; -import dev.galasa.sem.SemManagerException; -import dev.galasa.sem.internal.properties.ModelApplids; - -public class SemPoolApplids implements IPool { - - private static final Log logger = LogFactory.getLog(SemPoolApplids.class); - - private final SemManagerImpl manager; - private final IDynamicStatusStoreService dss; - private final IResourcePoolingService rps; - - private final String runName; - - private final List resourceStrings; - - private final ArrayList rejectedApplids = new ArrayList<>(); - private final ArrayList availableApplids = new ArrayList<>(); - private final HashSet usedApplids = new HashSet<>(); - - public SemPoolApplids(SemManagerImpl manager, IDynamicStatusStoreService dss, IResourcePoolingService rps) throws SemManagerException { - this.manager = manager; - this.dss = dss; - this.rps = rps; - this.runName = this.manager.getFramework().getTestRunName(); - this.resourceStrings = ModelApplids.get(); - } - - - - private void reserveApplids() throws SemManagerException { - while(this.availableApplids.isEmpty()) { - List possibleApplids; - try { - possibleApplids = this.rps.obtainResources(this.resourceStrings, this.rejectedApplids, 10, 10, dss, "applid"); - - // Quickly reserve them to help maintain blocks of applids, will free them - for(String possibleApplid : possibleApplids) { - try { - this.dss.performActions( - new DssAdd("applid." + possibleApplid, this.runName), - new DssAdd("run." + this.runName + ".applid." + possibleApplid, "active"), - new DssResourceUpdate("applid." + possibleApplid + ".run", this.runName) - ); - this.availableApplids.add(possibleApplid); - logger.trace("Reserved APPLID '" + possibleApplid + "' for SEM complex"); - } catch (DynamicStatusStoreException e) { - this.rejectedApplids.add(possibleApplid); - } - } - } catch (InsufficientResourcesAvailableException e) { - throw new SemManagerException("Not enough applids for this run", e); - } - } - } - - - - @Override - public String getNextValue() { - if (availableApplids.isEmpty()) { - try { - reserveApplids(); - } catch (SemManagerException e) { - logger.error("Reservation of SEM APPLIDs failed",e); - } - } - - if (availableApplids.isEmpty()) { - return null; - } - - String nextApplid = availableApplids.remove(0); - usedApplids.add(nextApplid); - - logger.debug("Allocated APPLID '" + nextApplid + "' to SEM complex"); - - return nextApplid; - } - - public void generateComplete() { - for(String applid : this.availableApplids) { - freeApplid(applid); - logger.trace("Freed APPLID '" + applid + "' from reservation list"); - } - } - - - - private void freeApplid(String applid) { - try { - deleteDss(this.runName, applid, this.dss); - } catch(DynamicStatusStoreException e) { - logger.debug("Failed to release applid '" + applid + "', leaving for resource management",e); - } - } - - - - public void discard() { - // Free any applids remaining in available, shouldn't be, but just in case - - for(String applid : this.availableApplids) { - freeApplid(applid); - } - - // Free any used Applids - - for(String applid : this.usedApplids) { - //TODO Call commserver to reset the applid on the zos image - freeApplid(applid); - logger.debug("Discarded APPLID '" + applid + "'"); - } - } - - - - public void setSystem(String applid, String sysid) throws SemManagerException { - if (!usedApplids.contains(applid)) { - return; - } - - if (sysid == null || sysid.isEmpty()) { - return; - } - - try { - this.dss.performActions( - new DssUpdate("applid." + applid + ".image", sysid) - ); - } catch(DynamicStatusStoreException e) { - throw new SemManagerException("Failed to add applid systems in DSS",e); - } - } - - - - public static void deleteDss(String runName, String applid, IDynamicStatusStoreService dss) throws DynamicStatusStoreException { - - // TODO - Should be calling zoscommserver manager to deactive and reactive the applid - - dss.performActions( - new DssDelete("applid." + applid, null), - new DssDelete("applid." + applid + ".image", null), - new DssDelete("run." + runName + ".applid." + applid, null), - new DssResourceDeletePrefix("applid." + applid + ".")); - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolPorts.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolPorts.java deleted file mode 100644 index 930a8b60e..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolPorts.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.ibm.hursley.cicsts.test.sem.interfaces.complex.IPool; - -import dev.galasa.framework.spi.DssAdd; -import dev.galasa.framework.spi.DssDelete; -import dev.galasa.framework.spi.DssResourceDeletePrefix; -import dev.galasa.framework.spi.DssResourceUpdate; -import dev.galasa.framework.spi.DssUpdate; -import dev.galasa.framework.spi.DynamicStatusStoreException; -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IResourcePoolingService; -import dev.galasa.framework.spi.InsufficientResourcesAvailableException; -import dev.galasa.sem.SemManagerException; -import dev.galasa.sem.internal.properties.ModelPorts; - -public class SemPoolPorts implements IPool { - - private static final Log logger = LogFactory.getLog(SemPoolPorts.class); - - private final SemManagerImpl manager; - private final IDynamicStatusStoreService dss; - private final IResourcePoolingService rps; - - private final String runName; - - private final List resourceStrings; - - private final ArrayList rejectedPorts = new ArrayList<>(); - private final ArrayList availablePorts = new ArrayList<>(); - private final ArrayList usedPorts = new ArrayList<>(); - - public SemPoolPorts(SemManagerImpl manager, IDynamicStatusStoreService dss, IResourcePoolingService rps) throws SemManagerException { - this.manager = manager; - this.dss = dss; - this.rps = rps; - this.runName = this.manager.getFramework().getTestRunName(); - this.resourceStrings = ModelPorts.get(); - } - - - - private void reservePorts() throws SemManagerException { - while(this.availablePorts.isEmpty()) { - List possiblePorts; - try { - possiblePorts = this.rps.obtainResources(this.resourceStrings, this.rejectedPorts, 10, 10, dss, "port"); - - // Quickly reserve them to help maintain blocks of ports, will free them - for(String possiblePort : possiblePorts) { - try { - this.dss.performActions( - new DssAdd("port." + possiblePort, this.runName), - new DssAdd("run." + this.runName + ".port." + possiblePort, "active"), - new DssResourceUpdate("port." + possiblePort + ".run", this.runName) - ); - this.availablePorts.add(possiblePort); - logger.trace("Reserved PORT '" + possiblePort + "' for SEM complex"); - } catch (DynamicStatusStoreException e) { - this.rejectedPorts.add(possiblePort); - } - } - } catch (InsufficientResourcesAvailableException e) { - throw new SemManagerException("Not enough ports for this run", e); - } - } - } - - - - @Override - public String getNextValue() { - if (availablePorts.isEmpty()) { - try { - reservePorts(); - } catch (SemManagerException e) { - logger.error("Reservation of SEM PORTs failed",e); - } - } - - if (availablePorts.isEmpty()) { - return null; - } - - String nextPort = availablePorts.remove(0); - usedPorts.add(nextPort); - - logger.debug("Allocated PORT '" + nextPort + "' to SEM complex"); - - return nextPort; - } - - public void generateComplete() { - for(String port : this.availablePorts) { - freePort(port); - logger.trace("Freed PORT '" + port + "' from reservation list"); - } - } - - - - private void freePort(String port) { - try { - deleteDss(this.runName, port, this.dss); - } catch(DynamicStatusStoreException e) { - logger.debug("Failed to release port '" + port + "', leaving for resource management",e); - } - } - - - - public void discard() { - // Free any ports remaining in available, shouldn't be, but just in case - - for(String port : this.availablePorts) { - freePort(port); - } - - // Free any used Ports - - for(String port : this.usedPorts) { - //TODO Call commserver to reset the port on the zos image - freePort(port); - logger.debug("Discarded PORT '" + port + "'"); - } - } - - - - public void setSystem(String sysid) throws SemManagerException { - for(String port : usedPorts) { - try { - this.dss.performActions( - new DssUpdate("port." + port + ".image", sysid) - ); - } catch(DynamicStatusStoreException e) { - throw new SemManagerException("Failed to add port systems in DSS",e); - } - } - - } - - - - public static void deleteDss(String runName, String port, IDynamicStatusStoreService dss) throws DynamicStatusStoreException { - // TODO - Should be calling zoscommserver manager to deactive and reactive the port - - dss.performActions( - new DssDelete("port." + port, null), - new DssDelete("port." + port + ".image", null), - new DssDelete("run." + runName + ".port." + port, null), - new DssResourceDeletePrefix("port." + port + ".")); - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolResolver.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolResolver.java deleted file mode 100644 index 2deadb7b9..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemPoolResolver.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import com.ibm.hursley.cicsts.test.sem.interfaces.complex.IPool; -import com.ibm.hursley.cicsts.test.sem.interfaces.complex.IPoolResolver; -import com.ibm.hursley.cicsts.test.sem.interfaces.complex.ISymbolic; - -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IResourcePoolingService; -import dev.galasa.sem.SemManagerException; - -public class SemPoolResolver implements IPoolResolver { - - private final SemManagerImpl manager; - private final IDynamicStatusStoreService dss; - private final IResourcePoolingService rps; - - private final SemPoolApplids poolApplids; - private final SemPoolPorts poolPorts; - - protected SemPoolResolver(SemManagerImpl manager) throws SemManagerException { - this.manager = manager; - this.dss = this.manager.getDss(); - this.rps = this.manager.getFramework().getResourcePoolingService(); - - this.poolApplids = new SemPoolApplids(this.manager, dss, rps); - this.poolPorts = new SemPoolPorts(this.manager, dss, rps); - } - - @Override - public IPool getPool(String poolname, ISymbolic symbolicResolver, Object modelObject) { - - if ("APPLIDS".equalsIgnoreCase(poolname)) { - return this.poolApplids; - } - if ("PORTS".equalsIgnoreCase(poolname)) { - return this.poolPorts; - } - return null; - } - - public void generateComplete() { - this.poolApplids.generateComplete(); - this.poolPorts.generateComplete(); - } - - public void discard() { - this.poolApplids.discard(); - this.poolPorts.discard(); - } - - public SemPoolApplids getApplidPool() { - return this.poolApplids; - } - - public SemPoolPorts getPortPool() { - return this.poolPorts; - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemZosHandler.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemZosHandler.java deleted file mode 100644 index f0b10b0f6..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SemZosHandler.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.ibm.hursley.cicsts.test.sem.complex.IOSFileSupplier; -import com.ibm.hursley.cicsts.test.sem.complex.ZOSJobSupplier; -import com.ibm.hursley.cicsts.test.sem.complex.jcl.JCLException; -import com.ibm.hursley.cicsts.test.sem.complex.jcl.Job; -import com.ibm.hursley.cicsts.test.sem.complex.jcl.Step; - -import dev.galasa.sem.SemManagerException; -import dev.galasa.zos.IZosImage; -import dev.galasa.zos.spi.IZosManagerSpi; -import dev.galasa.zosbatch.IZosBatch; -import dev.galasa.zosbatch.IZosBatchJob; -import dev.galasa.zosbatch.IZosBatchJob.JobStatus; -import dev.galasa.zosbatch.IZosBatchJobOutputSpoolFile; -import dev.galasa.zosbatch.IZosBatchJobname; -import dev.galasa.zosbatch.spi.IZosBatchSpi; - -public class SemZosHandler implements IOSFileSupplier, ZOSJobSupplier { - - private static final Log logger = LogFactory.getLog(SemZosHandler.class); - - private IZosManagerSpi zosManager; - private IZosBatchSpi zosBatch; - private IZosImage primaryZosImage; - private IZosImage secondaryZosImage; - - private ArrayList batchJobs = new ArrayList<>(); - - public SemZosHandler(IZosManagerSpi zosManager, IZosBatchSpi zosBatch, IZosImage primaryZosImage, IZosImage secondaryZosImage) throws SemManagerException { - this.zosManager = zosManager; - this.zosBatch = zosBatch; - this.primaryZosImage = primaryZosImage; - this.secondaryZosImage = secondaryZosImage; - - } - - @Override - public void submitJob(Job job) throws JCLException { - try { - String jcl = generateJCL(job); - - // Get the system to submit the job on - IZosImage zosImage = null; - String system = job.getSystem(); - if (system == null) { - zosImage = this.primaryZosImage; - } else { - if (this.primaryZosImage.getSysname().equals(system)) { - zosImage = this.primaryZosImage; - } else if (this.secondaryZosImage.getSysname().equals(system)) { - zosImage = this.secondaryZosImage; - } else { - throw new JCLException("Unable to submit job as system '" + system + "' is unknown to the SEM Manager"); - } - } - - IZosBatchJobname jobname = this.zosManager.newZosBatchJobname(zosImage); - IZosBatch batch = this.zosBatch.getZosBatch(this.primaryZosImage); - IZosBatchJob batchJob = batch.submitJob(jcl, jobname); - - job.setMvsJob(batchJob); - - this.batchJobs.add(batchJob); - - } catch(Exception e) { - throw new JCLException("Unable to submit job", e); - } - } - - public String generateJCL(Job job) throws IllegalArgumentException, IllegalAccessException { - List steps = job.getSteps(); - - StringBuilder jcl = new StringBuilder(); - for(Step step : steps) { - if (step != null) { - for(String line : step.buildJCL()) { - jcl.append(line); - } - } - } - - return jcl.toString(); - } - - @Override - public boolean isJobOutputReady(Job job) { - IZosBatchJob batchJob = (IZosBatchJob) job.getMvsJob(); - - if (batchJob.getStatus() == JobStatus.OUTPUT) { - return true; - } - - return false; - } - - @Override - public void discardOutput(Job job) { - throw new UnsupportedOperationException("Not written yet"); - } - - @Override - public List getJobOutput(Job job) { - IZosBatchJob batchJob = (IZosBatchJob) job.getMvsJob(); - - try { - IZosBatchJobOutputSpoolFile output = batchJob.getSpoolFile("JESYSMSG"); - String records = output.getRecords(); - - - ArrayList lines = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new StringReader(records))) { - String line = null; - while((line = br.readLine()) != null) { - if (line.length() > 2) { - lines.add(line.substring(1)); // remove the ASA - } - } - } - - return lines; - } catch (Exception e) { - logger.error("Failed to retrieve output for " + batchJob,e); - return new ArrayList<>(); - } - } - - @Override - public void cancelConflictingJobnames(ArrayList jobnames) throws IOException { - // Ignoring this as the zOS Batch Manager should cater for this - } - - @Override - public boolean isJobnameOnExcecutionQueue(String jobname) throws IOException { - // Ignoring as zOS Batch Manager takes responsibility - return false; - } - - @Override - public List getJesMsgLg(Job job) { - throw new UnsupportedOperationException("Not written yet"); - // return null; - } - - @Override - public void cancelJob(Job job) { - throw new UnsupportedOperationException("Not written yet"); - } - - @Override - public BufferedReader getFile(String filename) throws FileNotFoundException, IOException { - throw new UnsupportedOperationException("Not written yet"); - // return null; - } - - protected List getJobs() { - return this.batchJobs; - } - - protected void clearJobs() { - this.batchJobs.clear(); - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SitGenerator.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SitGenerator.java deleted file mode 100644 index 0c87bd067..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/SitGenerator.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal; - -import java.util.HashMap; - -import sem.Environment; -import sem.SIT; -import sem.SITGroup; -import sem.SemFactory; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import dev.galasa.sem.SemManagerException; -import dev.galasa.sem.Sit; -import dev.galasa.sem.Sits; - -public class SitGenerator { - - private static final Log logger = LogFactory.getLog(CsdInputGenerator.class); - private final SemManagerImpl semManager; - - private HashMap sitGroups = new HashMap(); - - - public SitGenerator(SemManagerImpl semManager) { - this.semManager = semManager; - } - - public void generate(Environment environment, Class testClass) throws SemManagerException { - Sits sits = testClass.getAnnotation(Sits.class); - if (sits != null) { - processSits(environment, sits, testClass); - } - - Sit sit = testClass.getAnnotation(Sit.class); - if (sit != null) { - processSit(environment, sit, testClass); - } - } - - private void processSits(Environment environment, Sits sits, Class testClass) throws SemManagerException { - for(Sit sit : sits.value()) { - processSit(environment, sit, testClass); - } - } - - private void processSit(Environment environment, Sit sit, Class testClass) throws SemManagerException { - - String tag = sit.cicsTag().trim().toUpperCase(); - String parameter = sit.parameter().trim().toUpperCase(); - String value = sit.value().trim(); - - String className = testClass.getName(); - - if (parameter.equals("GRPLIST")) { - throw new SemManagerException("GRPLIST is not allowed to be specified on @Sit annotations"); - } - if (parameter.equals("APPLID")) { - throw new SemManagerException("APPLID is not allowed to be specified on @Sit annotations"); - } - - // if there is no sitGroup for the current tag we want to create one - if(!sitGroups.containsKey(tag)) { - SITGroup sitGroup = SemFactory.eINSTANCE.createSITGroup(); - - sitGroup.setName("SITs " + className + "(" + tag + ")"); - - // if the sit has the default tag "UNTAGGED" it will apply to all cics' - // otherwise we want to create a condition to apply it to the cics with the - // corresponding tag - if (!tag.equals("UNTAGGED")) { - sitGroup.setCondition("&TAG(" + tag + ") = 'YES'"); - } - - sitGroups.put(tag, sitGroup); - - sitGroup.setPARENT(environment); - } - - // create the sit itself and add it to the correct group - SIT generatedSit = SemFactory.eINSTANCE.createSIT(); - generatedSit.setParm(parameter); - generatedSit.setValue("#" + value); - generatedSit.setPARENT(sitGroups.get(tag)); - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/BaseModel.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/BaseModel.java deleted file mode 100644 index c57805819..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/BaseModel.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class BaseModel extends CpsProperties { - - public static String get() throws SemManagerException { - return getStringWithDefault(SemPropertiesSingleton.cps(), "Base", "base", "model"); - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/CicsBuild.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/CicsBuild.java deleted file mode 100644 index 6ace76e27..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/CicsBuild.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import dev.galasa.framework.spi.ConfigurationPropertyStoreException; -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class CicsBuild extends CpsProperties { - - public static String get() throws SemManagerException { - try { - return getStringNulled(SemPropertiesSingleton.cps(), "build", "level"); - } catch (ConfigurationPropertyStoreException e) { - throw new SemManagerException("Problem accessing sem.build.level", e); - } - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ExternalVersion.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ExternalVersion.java deleted file mode 100644 index 7eeb102d5..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ExternalVersion.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import dev.galasa.ManagerException; -import dev.galasa.ProductVersion; -import dev.galasa.framework.spi.ConfigurationPropertyStoreException; -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class ExternalVersion extends CpsProperties { - - public static ProductVersion get(String version) throws SemManagerException { - try { - String internalVersion = getStringNulled(SemPropertiesSingleton.cps(), "external.version", version); - if (internalVersion == null) { - throw new SemManagerException("Version '" + version + "' does not have an external version"); - } - - try { - return ProductVersion.parse(internalVersion); - } catch(ManagerException e) { - throw new SemManagerException("Internal version was not recognised '" + version + "'", e); - } - } catch(ConfigurationPropertyStoreException e) { - throw new SemManagerException("Problem retrieving external version from CPS for '" + version + "'", e); - } - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/InteralVersion.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/InteralVersion.java deleted file mode 100644 index 7b07aa100..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/InteralVersion.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import dev.galasa.ProductVersion; -import dev.galasa.framework.spi.ConfigurationPropertyStoreException; -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class InteralVersion extends CpsProperties { - - public static String get(ProductVersion version) throws SemManagerException { - try { - String internalVersion = getStringNulled(SemPropertiesSingleton.cps(), "internal.version", version.toString()); - if (internalVersion == null) { - throw new SemManagerException("Version '" + version + "' does not have an internal version"); - } - - return internalVersion; - } catch(ConfigurationPropertyStoreException e) { - throw new SemManagerException("Problem retrieving internal version from CPS for '" + version.toString() + "'", e); - } - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelApplids.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelApplids.java deleted file mode 100644 index c034ff684..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelApplids.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import java.util.List; - -import javax.validation.constraints.NotNull; - -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class ModelApplids extends CpsProperties { - - public static @NotNull List get() throws SemManagerException { - return getStringListWithDefault(SemPropertiesSingleton.cps(), "GAL{0-9}", "model", "applids"); - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelPorts.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelPorts.java deleted file mode 100644 index 17e671529..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelPorts.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import java.util.List; - -import javax.validation.constraints.NotNull; - -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class ModelPorts extends CpsProperties { - - public static @NotNull List get() throws SemManagerException { - return getStringListWithDefault(SemPropertiesSingleton.cps(), "30000-30010", "model", "ports"); - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelUrl.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelUrl.java deleted file mode 100644 index 4127133a4..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/ModelUrl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import java.net.MalformedURLException; -import java.net.URL; - -import dev.galasa.framework.spi.ConfigurationPropertyStoreException; -import dev.galasa.framework.spi.cps.CpsProperties; -import dev.galasa.sem.SemManagerException; - -public class ModelUrl extends CpsProperties { - - public static URL get() throws SemManagerException { - try { - String url = getStringNulled(SemPropertiesSingleton.cps(), "model", "url"); - if (url == null) { - throw new SemManagerException("sem.model.url is missing from the CPS"); - } - - try { - return new URL(url); - } catch(MalformedURLException e) { - throw new SemManagerException("Unable to parse the sem.model.url '" + url + "'", e); - } - } catch(ConfigurationPropertyStoreException e) { - throw new SemManagerException("Problem accessing the CPS for the sem.model.url", e); - } - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/SemPropertiesSingleton.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/SemPropertiesSingleton.java deleted file mode 100644 index 8587a9f29..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/properties/SemPropertiesSingleton.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.properties; - -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; - -import dev.galasa.framework.spi.IConfigurationPropertyStoreService; -import dev.galasa.sem.SemManagerException; - -@Component(service=SemPropertiesSingleton.class, immediate=true) -public class SemPropertiesSingleton { - - private static SemPropertiesSingleton singletonInstance; - - private static void setInstance(SemPropertiesSingleton instance) { - singletonInstance = instance; - } - - private IConfigurationPropertyStoreService cps; - - @Activate - public void activate() { - setInstance(this); - } - - @Deactivate - public void deacivate() { - setInstance(null); - } - - public static IConfigurationPropertyStoreService cps() throws SemManagerException { - if (singletonInstance != null) { - return singletonInstance.cps; - } - - throw new SemManagerException("Attempt to access manager CPS before it has been initialised"); - } - - public static void setCps(IConfigurationPropertyStoreService cps) throws SemManagerException { - if (singletonInstance != null) { - singletonInstance.cps = cps; - return; - } - - throw new SemManagerException("Attempt to set manager CPS before instance created"); - } -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/ApplidResourceMonitor.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/ApplidResourceMonitor.java deleted file mode 100644 index 574aa2ee6..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/ApplidResourceMonitor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.resourcemanagement; - -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import dev.galasa.framework.spi.IConfigurationPropertyStoreService; -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IFramework; -import dev.galasa.framework.spi.IResourceManagement; -import dev.galasa.sem.internal.SemPoolApplids; - -public class ApplidResourceMonitor implements Runnable { - - private final IFramework framework; - private final IResourceManagement resourceManagement; - private final IDynamicStatusStoreService dss; - private final Log logger = LogFactory.getLog(this.getClass()); - private final Pattern applidRunPattern = Pattern.compile("^run\\.(\\w+)\\.applid\\.(\\w+)$"); - - public ApplidResourceMonitor(IFramework framework, - IResourceManagement resourceManagement, - IDynamicStatusStoreService dss, - SemResourceManagement semResourceManagement, - IConfigurationPropertyStoreService cps) { - this.framework = framework; - this.resourceManagement = resourceManagement; - this.dss = dss; - this.logger.info("SEM Applid resource monitor initialised"); - } - - - @Override - public void run() { - logger.info("Starting Run Applid search"); - try { - //*** Find all the runs with applids - Map runs = dss.getPrefix("run."); - - Set activeRunNames = this.framework.getFrameworkRuns().getActiveRunNames(); - - for(String key : runs.keySet()) { - Matcher matcher = applidRunPattern.matcher(key); - if (matcher.find()) { - String runName = matcher.group(1); - - if (!activeRunNames.contains(runName)) { - String applid = matcher.group(2); - - logger.info("Discarding applid " + applid + " as run " + runName + " has gone"); - - try { - SemPoolApplids.deleteDss(runName, applid, dss); - } catch(Exception e) { - logger.error("Failed to discard applid " + applid + " for run " + runName); - } - } - } - } - } catch(Exception e) { - logger.error("Failure during applid scan",e); - } - - this.resourceManagement.resourceManagementRunSuccessful(); - logger.info("Finished Run Applid search"); - } - - public void runFinishedOrDeleted(String runName) { - try { - Map applidRuns = dss.getPrefix("run." + runName + ".applid."); - for(String key : applidRuns.keySet()) { - Matcher matcher = applidRunPattern.matcher(key); - if (matcher.find()) { - String applid = matcher.group(2); - - logger.info("Discarding applid " + applid + " as run " + runName + " has gone"); - - try { - SemPoolApplids.deleteDss(runName, applid, dss); - } catch(Exception e) { - logger.error("Failed to discard applid " + applid + " for run " + runName); - } - } - } - } catch(Exception e) { - logger.error("Failed to delete applid for run " + runName); - } - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/PortResourceMonitor.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/PortResourceMonitor.java deleted file mode 100644 index 940090bfb..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/PortResourceMonitor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.resourcemanagement; - -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import dev.galasa.framework.spi.IConfigurationPropertyStoreService; -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IFramework; -import dev.galasa.framework.spi.IResourceManagement; -import dev.galasa.sem.internal.SemPoolPorts; - -public class PortResourceMonitor implements Runnable { - - private final IFramework framework; - private final IResourceManagement resourceManagement; - private final IDynamicStatusStoreService dss; - private final Log logger = LogFactory.getLog(this.getClass()); - private final Pattern portRunPattern = Pattern.compile("^run\\.(\\w+)\\.port\\.(\\w+)$"); - - public PortResourceMonitor(IFramework framework, - IResourceManagement resourceManagement, - IDynamicStatusStoreService dss, - SemResourceManagement semResourceManagement, - IConfigurationPropertyStoreService cps) { - this.framework = framework; - this.resourceManagement = resourceManagement; - this.dss = dss; - this.logger.info("SEM Port resource monitor initialised"); - } - - - @Override - public void run() { - logger.info("Starting Run Port search"); - try { - //*** Find all the runs with port - Map runs = dss.getPrefix("run."); - - Set activeRunNames = this.framework.getFrameworkRuns().getActiveRunNames(); - - for(String key : runs.keySet()) { - Matcher matcher = portRunPattern.matcher(key); - if (matcher.find()) { - String runName = matcher.group(1); - - if (!activeRunNames.contains(runName)) { - String port = matcher.group(2); - - logger.info("Discarding port " + port + " as run " + runName + " has gone"); - - try { - SemPoolPorts.deleteDss(runName, port, dss); - } catch(Exception e) { - logger.error("Failed to discard port " + port + " for run " + runName); - } - } - } - } - } catch(Exception e) { - logger.error("Failure during port scan",e); - } - - this.resourceManagement.resourceManagementRunSuccessful(); - logger.info("Finished Run Port search"); - } - - public void runFinishedOrDeleted(String runName) { - try { - Map portRuns = dss.getPrefix("run." + runName + ".port."); - for(String key : portRuns.keySet()) { - Matcher matcher = this.portRunPattern.matcher(key); - if (matcher.find()) { - String port = matcher.group(2); - - logger.info("Discarding port " + port + " as run " + runName + " has gone"); - - try { - SemPoolPorts.deleteDss(runName, port, dss); - } catch(Exception e) { - logger.error("Failed to discard port " + port + " for run " + runName); - } - } - } - } catch(Exception e) { - logger.error("Failed to delete port for run " + runName); - } - } - -} diff --git a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/SemResourceManagement.java b/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/SemResourceManagement.java deleted file mode 100644 index b91696799..000000000 --- a/galasa-managers-parent/galasa-managers-internal-parent/dev.galasa.sem.manager/src/main/java/dev/galasa/sem/internal/resourcemanagement/SemResourceManagement.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright contributors to the Galasa project - * - * SPDX-License-Identifier: EPL-2.0 - */ -package dev.galasa.sem.internal.resourcemanagement; - -import java.util.concurrent.TimeUnit; - -import org.osgi.service.component.annotations.Component; - -import dev.galasa.framework.spi.IConfigurationPropertyStoreService; -import dev.galasa.framework.spi.IDynamicStatusStoreService; -import dev.galasa.framework.spi.IFramework; -import dev.galasa.framework.spi.IResourceManagement; -import dev.galasa.framework.spi.IResourceManagementProvider; -import dev.galasa.framework.spi.ResourceManagerException; - -@Component(service= {IResourceManagementProvider.class}) -public class SemResourceManagement implements IResourceManagementProvider { - - private IFramework framework; - private IResourceManagement resourceManagement; - private IDynamicStatusStoreService dss; - private IConfigurationPropertyStoreService cps; - - private ApplidResourceMonitor applidResourceMonitor; - private PortResourceMonitor portResourceMonitor; - - @Override - public boolean initialise(IFramework framework, IResourceManagement resourceManagement) - throws ResourceManagerException { - - this.framework = framework; - this.resourceManagement = resourceManagement; - try { - this.dss = this.framework.getDynamicStatusStoreService("sem"); - this.cps = this.framework.getConfigurationPropertyService("sem"); - } catch (Exception e) { - throw new ResourceManagerException("Unable to initialise SEM resource monitor", e); - } - - this.applidResourceMonitor = new ApplidResourceMonitor(framework, resourceManagement, this.dss, this, cps); - this.portResourceMonitor = new PortResourceMonitor(framework, resourceManagement, this.dss, this, cps); - - return true; - } - - @Override - public void start() { - this.resourceManagement.getScheduledExecutorService().scheduleWithFixedDelay(this.applidResourceMonitor, - this.framework.getRandom().nextInt(20), - 60, - TimeUnit.SECONDS); - this.resourceManagement.getScheduledExecutorService().scheduleWithFixedDelay(this.portResourceMonitor, - this.framework.getRandom().nextInt(60), - 60, - TimeUnit.SECONDS); - } - - @Override - public void shutdown() { - } - - @Override - public void runFinishedOrDeleted(String runName) { - this.applidResourceMonitor.runFinishedOrDeleted(runName); - this.portResourceMonitor.runFinishedOrDeleted(runName); - } - -} diff --git a/galasa-managers-parent/settings.gradle b/galasa-managers-parent/settings.gradle index 767ec2472..036c82c4a 100644 --- a/galasa-managers-parent/settings.gradle +++ b/galasa-managers-parent/settings.gradle @@ -99,6 +99,3 @@ include 'galasa-managers-ides-parent:dev.galasa.eclipseruntime.ubuntu.manager' // galasa-managers-workflow-parent include 'galasa-managers-workflow-parent:dev.galasa.githubissue.manager' - -// galasa-managers-internal-parent -include 'galasa-managers-internal-parent:dev.galasa.sem.manager' diff --git a/release.yaml b/release.yaml index cc12d88bf..b7fb1091f 100644 --- a/release.yaml +++ b/release.yaml @@ -88,7 +88,7 @@ managers: codecoverage: true - artifact: dev.galasa.cicsts.manager.ivt - version: 0.25.0 + version: 0.38.0 obr: true mvp: true bom: false @@ -303,15 +303,6 @@ managers: isolated: false codecoverage: false - - artifact: dev.galasa.sem.manager - version: 0.36.0 - obr: true - mvp: false - bom: true - javadoc: false - isolated: false - codecoverage: false - - artifact: dev.galasa.java.manager version: 0.21.0 obr: true