Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSE-1026 Testdeck Migration: 10 Tests #8901

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.rundeck.tests.functional.api.ResponseModels

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty

@JsonIgnoreProperties(ignoreUnknown = true)
class Node {
@JsonProperty("nodename")
String nodename
@JsonProperty("hostname")
String hostname
@JsonProperty("osFamily")
String osFamily
@JsonProperty("osVersion")
String osVersion
@JsonProperty("osArch")
String osArch
@JsonProperty("description")
String description
@JsonProperty("osName")
String osName
@JsonProperty("username")
String username
@JsonProperty("tags")
String tags
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.rundeck.tests.functional.api.ResponseModels

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty

@JsonIgnoreProperties(ignoreUnknown = true)
class RunCommand {
@JsonProperty("message")
String message
@JsonProperty("execution")
Execution execution
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package org.rundeck.tests.functional.api.ResponseModels

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty

@JsonIgnoreProperties(ignoreUnknown = true)
class SystemInfo {
System system

static class System {
Executions executions
Extended extended
Healthcheck healthcheck
Jvm jvm
Metrics metrics
Os os
Ping ping
Rundeck rundeck
Stats stats
ThreadDump threadDump
Timestamp timestamp
}

static class Executions {
String active
String executionMode
}

static class Extended {
@JsonProperty("RundeckPro")
RundeckPro rundeckPro
}

static class RundeckPro {
String version
String buildGit
String edition
}

static class Healthcheck {
String contentType
String href
}

static class Jvm {
String implementationVersion
String name
String vendor
String version
}

static class Metrics {
String contentType
String href
}

static class Os {
String arch
String name
String version
}

static class Ping {
String contentType
String href
}

static class Rundeck {
String apiversion
String base
String build
@JsonProperty("buildGit")
String buildGitVersion
String node
String serverUUID
String version
}

static class Stats {
Cpu cpu
Memory memory
Scheduler scheduler
Threads threads
Uptime uptime
}

static class Cpu {
LoadAverage loadAverage
int processors
}

static class LoadAverage {
int average
String unit
}

static class Memory {
long free
long max
long total
String unit
}

static class Scheduler {
int running
int threadPoolSize
}

static class Threads {
int active
}

static class Uptime {
long duration
Duration since
String unit
}

static class Duration {
String datetime
long epoch
String unit
}

static class ThreadDump {
String contentType
String href
}

static class Timestamp {
String datetime
long epoch
String unit
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.rundeck.tests.functional.api.basic

import org.rundeck.util.annotations.APITest
import org.rundeck.util.container.BaseContainer
import org.rundeck.util.container.RdClient

@APITest
class BasicSpec extends BaseContainer {
Expand Down Expand Up @@ -40,5 +39,4 @@ class BasicSpec extends BaseContainer {
json.error
json.message == "Invalid API Request: /api/45/dnexist"
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.rundeck.tests.functional.api.project

import org.rundeck.tests.functional.api.ResponseModels.ConfigProperty
import org.rundeck.tests.functional.api.ResponseModels.Execution
import org.rundeck.tests.functional.api.ResponseModels.ProjectCreateResponse
import org.rundeck.util.annotations.APITest
import org.rundeck.util.container.BaseContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.rundeck.tests.functional.api.project

import org.rundeck.tests.functional.api.ResponseModels.Execution
import org.rundeck.tests.functional.api.ResponseModels.RunCommand
import org.rundeck.util.annotations.APITest
import org.rundeck.util.container.BaseContainer
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper

@APITest
class RunCommandSpec extends BaseContainer{

def setupSpec() {
startEnvironment()
setupProject()
}

def "test-run-command"(){
given:
def client = getClient()
def mapper = new ObjectMapper()
def projectName = PROJECT_NAME
def execArgs = "echo 'this is a test of /api/run/command'"

when:
def runResponse = client.doPostWithoutBody("/project/$projectName/run/command?exec=${execArgs}")
def runResponseBody = runResponse.body().string()
def parsedResponseBody = mapper.readValue(runResponseBody, RunCommand.class)
def newExecId = parsedResponseBody.execution.id

then:
noExceptionThrown()
newExecId > 0
mapper.readValue(client.doGetAcceptAll("/execution/$newExecId").body().string(), Execution.class) != null //extra validation to check if exec exists
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.rundeck.tests.functional.api.project

import com.fasterxml.jackson.databind.ObjectMapper
import org.rundeck.tests.functional.api.ResponseModels.Execution
import org.rundeck.tests.functional.api.ResponseModels.RunCommand
import org.rundeck.util.annotations.APITest
import org.rundeck.util.api.ExecutionStatus
import org.rundeck.util.api.JobUtils
import org.rundeck.util.api.WaitingTime
import org.rundeck.util.container.BaseContainer

@APITest
class RunUrlSpec extends BaseContainer{

def setupSpec() {
startEnvironment()
setupProject()
}

def "test-run-url-v14"(){
given:
def projectName = PROJECT_NAME
def client = getClient()
def mapper = new ObjectMapper()

when: "should fail with no url param"
def noParamsResponse = client.doGetAcceptAll("/project/$projectName/run/url")
def parsedNoParamsResponse = mapper.readValue(noParamsResponse.body().string(), Object.class)

then: "should fail with no url param"
noParamsResponse.code() == 400
parsedNoParamsResponse.errorCode == "api.error.parameter.required"
parsedNoParamsResponse.error
parsedNoParamsResponse.message == "parameter \"scriptURL\" is required"

when:
def scriptLocation = "/home/rundeck/simpleScript.sh"
def scriptArg = "file:$scriptLocation"
def scriptExecArgsResponse = client.doGetAcceptAll("/project/$projectName/run/url?scriptURL=$scriptArg")
def parsedScriptExecArgs = mapper.readValue(scriptExecArgsResponse.body().string(), RunCommand.class)
def scriptExecId = parsedScriptExecArgs.execution.id

then:
scriptExecArgsResponse.code() == 200
scriptExecId > 0
mapper.readValue(client.doGetAcceptAll("/execution/$scriptExecId").body().string(), Execution.class) != null

when: "We check the execution status"
def succeededExec = JobUtils.waitForExecutionToBe(
ExecutionStatus.SUCCEEDED.state,
scriptExecId as String,
mapper,
client,
WaitingTime.LOW.milliSeconds,
WaitingTime.MODERATE.milliSeconds / 1000 as int
)

then:
succeededExec.status == ExecutionStatus.SUCCEEDED.state
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import okhttp3.Response
import okhttp3.ResponseBody
import org.jetbrains.annotations.NotNull

import java.time.Duration
import java.util.concurrent.TimeUnit
import java.util.function.Consumer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ services:
- "../../../tokens.properties:/home/rundeck/server/config/tokens.properties"
- "../../../realm.properties:/home/rundeck/server/config/realm.properties"
- "../../../resource-model:/home/rundeck/server/config/resource-model"
- "../../../test-files/job-run-steps-test-script1.txt:/home/rundeck/job-run-steps-test-script1.txt"
- "../../../test-files/job-run-steps-test-script1.txt:/home/rundeck/job-run-steps-test-script1.txt"
- "../../../test-files/simpleScript.sh:/home/rundeck/simpleScript.sh"
3 changes: 3 additions & 0 deletions functional-test/src/test/resources/test-files/simpleScript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo this is a script
54 changes: 0 additions & 54 deletions test/api/test-require-version.sh

This file was deleted.