-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anatoli Kalbasin <[email protected]>
- Loading branch information
1 parent
fba1e5c
commit d431067
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/test/kotlin/org/zowe/zdevops/declarative/jobs/PerformMvsCommandDeclarativeSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright (c) 2024 IBA Group. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBA Group | ||
* Zowe Community | ||
*/ | ||
|
||
package org.zowe.zdevops.classic.steps | ||
|
||
import hudson.EnvVars | ||
import hudson.FilePath | ||
import io.kotest.assertions.assertSoftly | ||
import io.kotest.core.spec.style.ShouldSpec | ||
import io.kotest.engine.spec.tempdir | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.string.shouldContain | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.spyk | ||
import okhttp3.mockwebserver.MockResponse | ||
import okhttp3.mockwebserver.MockWebServer | ||
import org.zowe.kotlinsdk.zowe.client.sdk.core.ZOSConnection | ||
import org.zowe.zdevops.MOCK_SERVER_HOST | ||
import org.zowe.zdevops.MockResponseDispatcher | ||
import org.zowe.zdevops.MockServerFactory | ||
import org.zowe.zdevops.declarative.jobs.PerformMvsCommandDeclarative | ||
import java.io.File | ||
import java.io.PrintStream | ||
import java.nio.file.Paths | ||
|
||
class PerformMvsCommandDeclarativeSpec : ShouldSpec({ | ||
lateinit var mockServer: MockWebServer | ||
lateinit var responseDispatcher: MockResponseDispatcher | ||
val mockServerFactory = MockServerFactory() | ||
|
||
beforeSpec { | ||
mockServer = mockServerFactory.startMockServer(MOCK_SERVER_HOST) | ||
responseDispatcher = mockServerFactory.responseDispatcher | ||
} | ||
afterSpec { | ||
mockServerFactory.stopMockServer() | ||
} | ||
context("declarative/jobs module: PerformMvsCommandStep") { | ||
val zosConnection = ZOSConnection(mockServer.hostName, mockServer.port.toString(), "test", "test", "https") | ||
val trashDir = tempdir() | ||
val trashDirWithInternal = Paths.get(trashDir.absolutePath, "test_name").toString() | ||
val workspace = FilePath(File(trashDirWithInternal)) | ||
val env = EnvVars() | ||
|
||
afterEach { | ||
responseDispatcher.removeAllEndpoints() | ||
} | ||
should("perform PerformMvsCommandDeclarative operation and return its result") { | ||
var isPreExecuteStage = false | ||
var isCommandExecuted = false | ||
val expectedPartialMvsDisplayActiveCommandOutput = "CNZ4105I 12.56.27 DISPLAY ACTIVITY" | ||
val taskListener = object : TestBuildListener() { | ||
override fun getLogger(): PrintStream { | ||
val logger = mockk<PrintStream>() | ||
every { | ||
logger.println(any<String>()) | ||
} answers { | ||
if (firstArg<String>().contains("Issuing command")) { | ||
isPreExecuteStage = true | ||
} else if (firstArg<String>().contains("The command has been successfully executed")) { | ||
isCommandExecuted = true | ||
} | ||
} | ||
return logger | ||
} | ||
} | ||
|
||
responseDispatcher.injectEndpoint( | ||
this.testCase.name.testName, | ||
{ it?.requestLine?.contains("PUT /zosmf/restconsoles/consoles/") ?: false }, | ||
{ MockResponse() | ||
.setResponseCode(200) | ||
.setBody(responseDispatcher.readMockJson("displayActiveASCommandOutput") ?: "") } | ||
) | ||
|
||
val performMvsCommandInst = spyk( | ||
PerformMvsCommandDeclarative("D A,L") | ||
) | ||
val mvsCommandResult = performMvsCommandInst.run(workspace, taskListener, env, zosConnection) | ||
|
||
assertSoftly { mvsCommandResult shouldContain expectedPartialMvsDisplayActiveCommandOutput } | ||
assertSoftly { isPreExecuteStage shouldBe true } | ||
assertSoftly { isCommandExecuted shouldBe true } | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cmd-response-key": "C1977656", | ||
"cmd-response-url": "https://192.168.1.1:10443/zosmf/restconsoles/consoles/defcn/solmsgs/C1977656", | ||
"cmd-response-uri": "/zosmf/restconsoles/consoles/defcn/solmsgs/C1977656", | ||
"cmd-response": " CNZ4105I 12.56.27 DISPLAY ACTIVITY 546\r JOBS M/S TS USERS SYSAS INITS ACTIVE/MAX VTAM OAS\r 00020 00040 00004 00034 00025 00002/00040 00041\r LLA LLA LLA NSW S JES2 JES2 IEFPROC NSW S\r VLF VLF VLF NSW S VTAM VTAM VTAM NSW S\r DLF DLF DLF NSW S RACF RACF RACF NSW S\r RRS RRS RRS NSW S TSO TSO STEP1 OWT S\r SDSF SDSF SDSF NSW S TCPIP TCPIP TCPIP NSW SO\r TN3270 TN3270 TN3270 NSW SO DBCGMSTR DBCGMSTR IEFPROC NSW S\r SDSFAUX SDSFAUX SDSFAUX NSW S HTTPD1 HTTPD1 *OMVSEX OWT SO\r NFSS NFSS GFSAMAIN NSW SO CSF CSF CSF NSW S\r HZSPROC HZSPROC HZSSTEP NSW SO DBCGIRLM DBCGIRLM NSW S\r DBCGDBM1 DBCGDBM1 IEFPROC NSW S CICSTS55 CICSTS55 CICS NSW SO\r IMS15RL1 IMS15RL1 DXRJPROC NSW S DBCGDIST DBCGDIST IEFPROC NSW SO\r IMS15CR1 IMS15CR1 IEFPROC NSW S DBCGADMT DBCGADMT STARTADM IN SO\r CSQ9MSTR CSQ9MSTR PROCSTEP NSW S CSQ9CHIN CSQ9CHIN PROCSTEP IN SO\r IMS15DL1 IMS15DL1 IEFPROC NSW S IMS15RC1 IMS15RC1 IEFPROC NSW S\r ASCH ASCH ASCH NSW S JMON JMON JMON OWT SO\r RSED RSED RSED OWT SO FTPD1 STEP1 FTPD OWT AO\r CFZCIM CFZCIM *OMVSEX OWT SO PAGENT PAGENT PAGENT OWT SO\r PORTMAP PORTMAP PMAP OWT SO SSHD3 STEP1 START1 OWT AO\r HTTPD13 STEP1 WEBSRV OWT AO BUZAGNT BUZAGNT BUZAGNT OWT SO\r ZOSCSRV ZOSCSRV ZCONNECT IN SO HTTPD19 STEP1 WEBSRV IN AO\r BUZAGNT1 *OMVSEX START1 IN AO BLZBFA3 STEP1 STCBFA OWT AO\r HTTPD11 STEP1 WEBSRV IN AO HTTPD12 STEP1 WEBSRV OWT AO\r BUZAGNT3 *OMVSEX START1 IN AO IMS15M11 IMS15M11 REGION NSW J\r IMS15F11 IMS15F11 IFP NSW J IMS15F12 IMS15F12 IFP NSW J\r IMS15F13 IMS15F13 IFP NSW J IMS15J11 IMS15J11 JMPRGN NSW JO\r RSED9 STEP1 STCRSE OWT AO RSED1 STEP1 STCRSE OWT AO\r RSED1 STEP1 STCRSE OWT AO RSED2 STEP1 STCRSE OWT AO\r RSED3 STEP1 STCRSE OWT AO RSED4 STEP1 STCRSE OWT AO\r APPC APPC APPC NSW S RMF RMF IEFPROC NSW S\r RMFGAT RMFGAT IEFPROC NSW SO AUTOMAN AUTOMAN AUTOMAN NSW S\r CICADM OWT KIRJU OWT KBA OWT O KBA IN O" | ||
} |