Skip to content

Commit

Permalink
Ecpappserverwebsphere 591 (#278)
Browse files Browse the repository at this point in the history
* create Cluster Helper

* moved methodes into helper

* added methodes and variables to WebSphereClusterHelper.groovy

* moved methodes to helper class

* moved methodes to helper class

* moved methodes to helper

* added to helper methodes from ListClusterMembersSpecSuite

* moved method getClusterBaseInfo to helper

* added methedes from RemoveClusterMembersSpecSuite

* moved code to helper

* fix function

* moved code to helper

* added method doesClusterExist in helper

* added methodes from CreateClusterSpecSuite

* moved code from CreateClusterSpecSuite to helper

* moved code to helper

* moved code to helper

* added procedures parameters

* moved variable projectName
  • Loading branch information
eserbin authored and Pavel-Vovk committed Nov 15, 2018
1 parent 0075a2e commit f556acc
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 2,001 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,13 @@ import com.electriccloud.plugin.spec.PluginTestHelper


@Requires({ System.getenv('IS_WAS_ND') == "1"})
class DeleteClusterSpecSuite extends PluginTestHelper {
// Environments Variables
@Shared
def wasUserName = System.getenv('WAS_USERNAME'),
wasPassword = System.getenv('WAS_PASSWORD'),
wasHost = System.getenv('WAS_HOST'),
wasPort = System.getenv('WAS_PORT'),
wasConnType = System.getenv('WAS_CONNTYPE'),
wasDebug = System.getenv('WAS_DEBUG'),
wasPath = System.getenv('WSADMIN_PATH'),
wasAppPath = System.getenv('WAS_APPPATH'),
is_windows = System.getenv("IS_WINDOWS")

@Shared
def servers = [
'default': 'server1',
]
class DeleteClusterSpecSuite extends WebSphereClusterHelper {

@Shared
def nodes = [
'default': wasHost + 'Node01',
]
def mainProcedure = procDeleteCluster

@Shared
def confignames = [
/**
* Required
*/
empty: '',
correctSOAP: 'Web-Sphere-SOAP',
wrongConfig: 'wrongConfig'
]
def projectName = "EC-WebSphere Specs $mainProcedure Project"

@Shared
def TC = [
Expand All @@ -53,7 +28,7 @@ class DeleteClusterSpecSuite extends PluginTestHelper {
def summaries = [
'default': "Cluster CLUSTERNAME has been deleted\n",
'emptyConfig': "Configuration '' doesn't exist",
'wrongConfig': "Configuration 'wrongConfig' doesn't exist",
'wrongConfig': "Configuration 'incorrect' doesn't exist",
'wrongCluster': "Failed to delete cluster.\n" +
"Error: Cluster CLUSTERNAME does not exist\n",
'runningCluster': "Failed to delete cluster.\n" +
Expand All @@ -69,84 +44,15 @@ class DeleteClusterSpecSuite extends PluginTestHelper {
wrongCluster: ["Failed to delete cluster", "Exception: ADMG9216E: Cannot find cluster CLUSTERNAME"],
]

@Shared
def procCreateCluster = 'CreateCluster',
procDeleteCluster = 'DeleteCluster',
procStartCluster = 'StartCluster',
procStopCluster = 'StopCluster',
procRunJob = 'RunCustomJob',
projectName = "EC-WebSphere Specs $procDeleteCluster Project"

def doSetupSpec() {
def wasResourceName = wasHost
createWorkspace(wasResourceName)
createConfiguration(confignames.correctSOAP, [doNotRecreate: false])
importProject(projectName, 'dsl/RunProcedure.dsl', [projName: projectName,
resName : wasResourceName,
procName: procCreateCluster,
params : [
configname: '',
wasAddClusterMembers: '',
wasClusterMembersGenUniquePorts: '',
wasClusterMembersList: '',
wasClusterMemberWeight: '',
wasClusterName: '',
wasCreateFirstClusterMember: '',
wasFirstClusterMemberCreationPolicy: '',
wasFirstClusterMemberGenUniquePorts: '',
wasFirstClusterMemberName: '',
wasFirstClusterMemberNode: '',
wasFirstClusterMemberTemplateName: '',
wasFirstClusterMemberWeight: '',
wasPreferLocal: '',
wasServerResourcesPromotionPolicy: '',
wasSourceServerName: '',
wasSyncNodes: '',
]
])

importProject(projectName, 'dsl/RunProcedure.dsl', [projName: projectName,
resName : wasResourceName,
procName: procDeleteCluster,
params : [
configname: '',
wasClusterName: '',
wasSyncNodes: '',
]
])

importProject(projectName, 'dsl/RunProcedure.dsl', [projName: projectName,
resName : wasResourceName,
procName: procStartCluster,
params : [
configName: '',
wasClusterName: '',
wasTimeout: '',
]
])

importProject(projectName, 'dsl/RunProcedure.dsl', [projName: projectName,
resName : wasResourceName,
procName: procRunJob,
params : [
configname: '',
scriptfile: '',
scriptfilesource: '',
]
])

importProject(projectName, 'dsl/RunProcedure.dsl', [projName: projectName,
resName : wasResourceName,
procName: procStopCluster,
params : [
configName: '',
wasClusterName: '',
wasTimeout: '',
wasRippleStart: ''
]
])


importProcedure(projectName, wasResourceName, procCreateCluster)
importProcedure(projectName, wasResourceName, procDeleteCluster)
importProcedure(projectName, wasResourceName, procStartCluster)
importProcedure(projectName, wasResourceName, procStopCluster)
importProcedure(projectName, wasResourceName, procRunJob)
dsl 'setProperty(propertyName: "/plugins/EC-WebSphere/project/ec_debug_logToProperty", value: "/myJob/debug_logs")'
}

Expand All @@ -158,8 +64,14 @@ class DeleteClusterSpecSuite extends PluginTestHelper {
def numberOfTest = specificationContext.currentIteration.parent.iterationNameProvider.iterationCount
clusterName += numberOfTest

given: "Create Test Cluster"
createCluster(clusterName, clusterType)
given: "Create Test Cluster"
if (clusterType == 'notEmpty'){
createCluster(clusterName)
}
else {
createEmptyCluster(clusterName)
}
assert doesClusterExist(clusterName) == 'true'
if (clusterState == 'run'){
startCluster(clusterName)
}
Expand Down Expand Up @@ -203,7 +115,13 @@ class DeleteClusterSpecSuite extends PluginTestHelper {
clusterName += numberOfTest

given: "Create Test Cluster"
createCluster(clusterName, clusterType)
if (clusterType == 'notEmpty'){
createCluster(clusterName)
}
else {
createEmptyCluster(clusterName)
}
assert doesClusterExist(clusterName) == 'true'
startCluster(clusterName)

and: "Parameters for procedure"
Expand Down Expand Up @@ -272,94 +190,7 @@ class DeleteClusterSpecSuite extends PluginTestHelper {
TC.C366943 | confignames.correctSOAP | '' | '1' | 'error' | summaries.wrongCluster | summaries.wrongCluster
TC.C366943 | '' | 'DeleteCluster' | '1' | 'error' | summaries.emptyConfig | [summaries.emptyConfig]
TC.C366945 | confignames.correctSOAP | 'Wrong' | '1' | 'error' | summaries.wrongCluster | summaries.wrongCluster
TC.C366945 | confignames.wrongConfig | 'DeleteCluster' | '1' | 'error' | summaries.wrongConfig | [summaries.wrongConfig]
}

def createCluster(def clusterName, def clusterType){
def runEmptyParams = [
configname: confignames.correctSOAP,
wasAddClusterMembers: '0',
wasClusterMembersGenUniquePorts: '1',
wasClusterName: clusterName,
wasCreateFirstClusterMember: '0',
wasFirstClusterMemberGenUniquePorts: '1',
wasPreferLocal: '1',
wasSyncNodes: '1',
]
def runServerParams = [
configname: confignames.correctSOAP,
wasAddClusterMembers: '0',
wasClusterMembersGenUniquePorts: '1',
wasClusterName: clusterName,
wasCreateFirstClusterMember: '1',
wasFirstClusterMemberCreationPolicy: 'existing',
wasFirstClusterMemberGenUniquePorts: '1',
wasFirstClusterMemberName: clusterName + 'Server1',
wasFirstClusterMemberNode: nodes.default,
wasPreferLocal: '1',
wasSourceServerName: nodes.default + ':' + servers.default,
wasSyncNodes: '1',
wasServerResourcesPromotionPolicy: 'both',
]

def runParams = runServerParams
if (clusterType == "empty"){
runParams = runEmptyParams
}
runProcedure(runParams, procCreateCluster)
assert doesClusterExist(clusterName) == 'true'
TC.C366945 | confignames.incorrect | 'DeleteCluster' | '1' | 'error' | summaries.wrongConfig | [summaries.wrongConfig]
}

def startCluster(def clusterName) {
def runParams = [
configName: confignames.correctSOAP,
wasClusterName: clusterName,
wasTimeout: '100',
]
runProcedure(runParams, procStartCluster)
}

def doesClusterExist(clusterName){
def script = "print AdminClusterManagement.checkIfClusterExists(\\'${clusterName}\\')"
def runParams = [
configname: confignames.correctSOAP,
scriptfile: script,
scriptfilesource: 'newscriptfile',
]
def result = runProcedure(runParams, procRunJob)
def debugLog = getJobLogs(result.jobId)
return debugLog.split('\n')[-1]
}

def stopCluster(def clusterName){
def runParams = [
configName: confignames.correctSOAP,
wasClusterName: clusterName,
wasTimeout: '60',
wasRippleStart: '0'
]
runProcedure(runParams, procStopCluster)
}

def runProcedure(def parameters, def procedureName=procDeleteCluster) {
def parametersString = parameters.collect { k, v -> "$k: '$v'" }.join(', ')
def code = """
runProcedure(
projectName: '$projectName',
procedureName: '$procedureName',
actualParameter: [
$parametersString
]
)
"""
def result = dslWithTimeout(code)
waitUntil {
try {
jobCompleted(result)
} catch (Exception e) {
println e.getMessage()
}
}
return result
}
}
Loading

0 comments on commit f556acc

Please sign in to comment.