Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
updated sdv manager tests and workflows to match jvm changes
Browse files Browse the repository at this point in the history
Signed-off-by: Savvas Kyriacou <[email protected]>
  • Loading branch information
KirbyKatcher committed Aug 20, 2024
1 parent 86ff4d5 commit 90a580a
Show file tree
Hide file tree
Showing 10 changed files with 735 additions and 632 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'semeru'

- name: Print githash
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 6.9.2
gradle-version: 8.9

- name: Build Managers source code
if: github.event_name == 'push'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'semeru'

- name: Print githash
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 6.9.2
gradle-version: 8.9

- name: Build Managers source code
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
}

jacoco {
toolVersion = "0.8.6"
toolVersion = "0.8.7"
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'galasa.manager'
id 'checkstyle'
id 'pmd'
id("com.github.spotbugs") version "4.7.0"
id("com.github.spotbugs") version "6.0.20"
}

description = 'Galasa SDV Manager'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<Match>
<Class name="dev.galasa.sdv.internal.properties.SdvPropertiesSingleton" />
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
</Match>
<Match>
<Class name="dev.galasa.sdv.internal.properties.SdvPropertiesSingleton" />
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR" />
</Match>
<Match>
<Class name="dev.galasa.sdv.internal.properties.SdvPropertiesSingleton" />
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import dev.galasa.zosbatch.IZosBatchJob;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -51,6 +50,7 @@
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import sun.misc.Unsafe;


class TestSdvManagerImpl {
Expand Down Expand Up @@ -93,7 +93,7 @@ class TestSdvManagerImpl {
private String frameworkString = "framework";
private String sdvRecorderVarName = "sdvRecorder";
private String logString = "LOG";
private String modifiersString = "modifiers";
private String theUnsafeString = "theUnsafe";
private String regionaApplid = "APPL1";
private String runName = "RUN123";
private String regionbApplid = "APPL2";
Expand Down Expand Up @@ -764,13 +764,14 @@ void testProvisionGenerateOldCicsVersionForRegionA()
sdvUsersToRecordList.set(sdvManager, listOfUsersForAllRegions);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionGenerate();
Expand Down Expand Up @@ -912,13 +913,14 @@ void testProvisionGenerateNoSecMsg() throws ClassNotFoundException, Instantiatio
sdvUsersToRecordList.set(sdvManager, listOfUsersForAllRegions);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionGenerate();
Expand Down Expand Up @@ -1057,13 +1059,14 @@ void testProvisionGenerateNoUsersForRegion()
sdvUsersToRecordList.set(sdvManager, listOfUsersForAllRegions);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionGenerate();
Expand Down Expand Up @@ -1422,13 +1425,14 @@ void testProvisionStopEndRecordingException() throws InstantiationException,
frameworkField.set(sdvManager, framework);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionStop();
Expand Down Expand Up @@ -1539,13 +1543,14 @@ void testProvisionStopReleaseUsersException() throws InstantiationException,
frameworkField.set(sdvManager, framework);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionStop();
Expand Down Expand Up @@ -1656,13 +1661,14 @@ void testProvisionStopcleanUpEnvironmentsException() throws InstantiationExcepti
frameworkField.set(sdvManager, framework);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionStop();
Expand Down Expand Up @@ -1896,13 +1902,14 @@ void testReleaseUsersException() throws CredentialsException, NoSuchFieldExcepti
frameworkField.set(sdvManager, framework);

// Replace LOG
Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
loggerField.setAccessible(true);
// remove final modifier
Field modifiersField = Field.class.getDeclaredField(modifiersString);
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
loggerField.set(sdvManager, mockLog);
final Field unsafeField = Unsafe.class.getDeclaredField(theUnsafeString);
unsafeField.setAccessible(true);
final Unsafe unsafe = (Unsafe) unsafeField.get(null);

final Field loggerField = sdvManagerImplClass.getDeclaredField(logString);
final Object staticLoggerFieldBase = unsafe.staticFieldBase(loggerField);
final long staticLoggerFieldOffset = unsafe.staticFieldOffset(loggerField);
unsafe.putObject(staticLoggerFieldBase, staticLoggerFieldOffset, mockLog);

// Make call to funtion under test
sdvManager.provisionStop();
Expand Down
Loading

0 comments on commit 90a580a

Please sign in to comment.