-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #501 from rundeck/fix/exit-code
RUN-1634: Fix exit codes on command failures
- Loading branch information
Showing
34 changed files
with
1,164 additions
and
116 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
...prise/src/test/groovy/org/rundeck/client/tool/commands/enterprise/cluster/ModeSpec.groovy
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,77 @@ | ||
package org.rundeck.client.tool.commands.enterprise.cluster | ||
|
||
import groovy.transform.CompileStatic | ||
import org.rundeck.client.api.model.ExecutionMode | ||
import org.rundeck.client.testing.MockRdTool | ||
import org.rundeck.client.tool.CommandOutput | ||
import org.rundeck.client.tool.RdApp | ||
import org.rundeck.client.tool.commands.enterprise.api.EnterpriseApi | ||
import org.rundeck.client.tool.commands.enterprise.api.model.EnterpriseModeResponse | ||
import org.rundeck.client.tool.commands.enterprise.api.model.LicenseResponse | ||
import org.rundeck.client.tool.commands.enterprise.license.License | ||
import org.rundeck.client.tool.extension.RdTool | ||
import org.rundeck.client.util.Client | ||
import org.rundeck.client.util.RdClientConfig | ||
import retrofit2.Retrofit | ||
import retrofit2.mock.Calls | ||
import spock.lang.Specification | ||
|
||
class ModeSpec extends Specification { | ||
private RdTool setupMock(EnterpriseApi api, CommandOutput out, int apiVersion) { | ||
def retrofit = new Retrofit.Builder().baseUrl('http://example.com/fake/').build() | ||
def client = new Client(api, retrofit, null, null, apiVersion, true, null) | ||
def rdapp = Mock(RdApp) { | ||
getClient(EnterpriseApi) >> client | ||
getAppConfig() >> Mock(RdClientConfig) | ||
getOutput() >> out | ||
} | ||
def rdTool = new MockRdTool(client: client, rdApp: rdapp) | ||
rdTool.appConfig = Mock(RdClientConfig) | ||
rdTool | ||
} | ||
|
||
def "active"() { | ||
def api = Mock(EnterpriseApi) | ||
def out = Mock(CommandOutput) | ||
RdTool rdTool = setupMock(api, out, 41) | ||
Mode command = new Mode() | ||
command.rdTool = rdTool | ||
def opts = new Mode.Options() | ||
opts.uuid = 'uuid' | ||
|
||
|
||
when: | ||
def result = command.active(opts) | ||
|
||
then: | ||
1 * api.executionModeEnable('uuid') >> Calls.response(new EnterpriseModeResponse(executionMode: respstatus as ExecutionMode)) | ||
0 * api._(*_) | ||
result == expected | ||
where: | ||
respstatus | expected | ||
'active' | 0 | ||
'passive' | 1 | ||
} | ||
def "passive"() { | ||
def api = Mock(EnterpriseApi) | ||
def out = Mock(CommandOutput) | ||
RdTool rdTool = setupMock(api, out, 41) | ||
Mode command = new Mode() | ||
command.rdTool = rdTool | ||
def opts = new Mode.Options() | ||
opts.uuid = 'uuid' | ||
|
||
|
||
when: | ||
def result = command.passive(opts) | ||
|
||
then: | ||
1 * api.executionModeDisable('uuid') >> Calls.response(new EnterpriseModeResponse(executionMode: respstatus as ExecutionMode)) | ||
0 * api._(*_) | ||
result == expected | ||
where: | ||
respstatus | expected | ||
'active' | 1 | ||
'passive' | 0 | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
...se/src/test/groovy/org/rundeck/client/tool/commands/enterprise/license/LicenseSpec.groovy
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,97 @@ | ||
package org.rundeck.client.tool.commands.enterprise.license | ||
|
||
import groovy.transform.CompileStatic | ||
import okhttp3.ResponseBody | ||
import org.rundeck.client.api.RundeckApi | ||
import org.rundeck.client.api.model.KeyStorageItem | ||
import org.rundeck.client.testing.MockRdTool | ||
import org.rundeck.client.tool.CommandOutput | ||
import org.rundeck.client.tool.RdApp | ||
import org.rundeck.client.tool.commands.enterprise.api.EnterpriseApi | ||
import org.rundeck.client.tool.commands.enterprise.api.model.LicenseResponse | ||
import org.rundeck.client.tool.extension.RdTool | ||
import org.rundeck.client.util.Client | ||
import org.rundeck.client.util.RdClientConfig | ||
import retrofit2.Retrofit | ||
import retrofit2.mock.Calls | ||
import spock.lang.Specification | ||
|
||
class LicenseSpec extends Specification { | ||
private RdTool setupMock(EnterpriseApi api, CommandOutput out, int apiVersion) { | ||
def retrofit = new Retrofit.Builder().baseUrl('http://example.com/fake/').build() | ||
def client = new Client(api, retrofit, null, null, apiVersion, true, null) | ||
def rdapp = Mock(RdApp) { | ||
getClient(EnterpriseApi) >> client | ||
getAppConfig() >> Mock(RdClientConfig) | ||
getOutput() >> out | ||
} | ||
def rdTool = new MockRdTool(client: client, rdApp: rdapp) | ||
rdTool.appConfig = Mock(RdClientConfig) | ||
rdTool | ||
} | ||
|
||
def "status"() { | ||
def api = Mock(EnterpriseApi) | ||
def out = Mock(CommandOutput) | ||
RdTool rdTool = setupMock(api, out, 41) | ||
License command = new License() | ||
command.rdTool = rdTool | ||
def opts = new License.StatusOpts() | ||
|
||
|
||
when: | ||
def result = command.status(opts) | ||
|
||
then: | ||
1 * api.verifyLicense() >> Calls.response(new LicenseResponse()) | ||
0 * api._(*_) | ||
result == 0 | ||
} | ||
|
||
def "status remaining"() { | ||
def api = Mock(EnterpriseApi) | ||
def out = Mock(CommandOutput) | ||
RdTool rdTool = setupMock(api, out, 41) | ||
License command = new License() | ||
command.rdTool = rdTool | ||
def opts = new License.StatusOpts() | ||
opts.remaining = optremain | ||
|
||
|
||
when: | ||
def result = command.status(opts) | ||
|
||
then: | ||
1 * api.verifyLicense() >> Calls.response(new LicenseResponse(remaining: remaining)) | ||
0 * api._(*_) | ||
result == expect | ||
where: | ||
optremain | remaining | expect | ||
10 | 10 | 0 | ||
10 | 9 | 1 | ||
10 | 0 | 1 | ||
} | ||
|
||
def "status expired"() { | ||
def api = Mock(EnterpriseApi) | ||
def out = Mock(CommandOutput) | ||
RdTool rdTool = setupMock(api, out, 41) | ||
License command = new License() | ||
command.rdTool = rdTool | ||
def opts = new License.StatusOpts() | ||
opts.status = true | ||
|
||
|
||
when: | ||
def result = command.status(opts) | ||
|
||
then: | ||
1 * api.verifyLicense() >> Calls.response(new LicenseResponse(active: active)) | ||
0 * api._(*_) | ||
result == expect | ||
where: | ||
active | expect | ||
true | 0 | ||
false | 1 | ||
} | ||
} |
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
Oops, something went wrong.