Rename BuildResponse and BuildRequest

parent ad5b2b66
......@@ -148,7 +148,7 @@ func (c *ExecCommand) buildOptions(config, jobConfig common.BuildOptions) (optio
return
}
func (c *ExecCommand) parseYaml(job string, build *common.GetBuildResponse) error {
func (c *ExecCommand) parseYaml(job string, build *common.JobResponse) error {
data, err := ioutil.ReadFile(".gitlab-ci.yml")
if err != nil {
return err
......@@ -222,7 +222,7 @@ func (c *ExecCommand) createBuild(repoURL string, abortSignal chan os.Signal) (b
}
build = &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
ID: 1,
ProjectID: 1,
RepoURL: repoURL,
......@@ -287,7 +287,7 @@ func (c *ExecCommand) Execute(context *cli.Context) {
logrus.Fatalln(err)
}
err = c.parseYaml(c.Job, &build.GetBuildResponse)
err = c.parseYaml(c.Job, &build.JobResponse)
if err != nil {
logrus.Fatalln(err)
}
......
......@@ -117,7 +117,7 @@ func (mr *RunCommand) processRunner(id int, runner *common.RunnerConfig, runners
defer mr.buildsHelper.release(runner)
// Receive a new build
buildData, healthy := mr.network.GetBuild(*runner)
buildData, healthy := mr.network.RequestJob(*runner)
mr.makeHealthy(runner.UniqueID(), healthy)
if buildData == nil {
return
......@@ -133,10 +133,10 @@ func (mr *RunCommand) processRunner(id int, runner *common.RunnerConfig, runners
// Create a new build
build := &common.Build{
GetBuildResponse: *buildData,
Runner: runner,
ExecutorData: context,
SystemInterrupt: mr.abortBuilds,
JobResponse: *buildData,
Runner: runner,
ExecutorData: context,
SystemInterrupt: mr.abortBuilds,
}
// Add build to list of builds to assign numbers
......
......@@ -64,7 +64,7 @@ func (r *RunSingleCommand) postBuild() {
}
func (r *RunSingleCommand) processBuild(data common.ExecutorData, abortSignal chan os.Signal) (err error) {
buildData, healthy := r.network.GetBuild(r.RunnerConfig)
buildData, healthy := r.network.RequestJob(r.RunnerConfig)
if !healthy {
log.Println("Runner is not healthy!")
select {
......@@ -85,10 +85,10 @@ func (r *RunSingleCommand) processBuild(data common.ExecutorData, abortSignal ch
config := common.NewConfig()
newBuild := common.Build{
GetBuildResponse: *buildData,
Runner: &r.RunnerConfig,
SystemInterrupt: abortSignal,
ExecutorData: data,
JobResponse: *buildData,
Runner: &r.RunnerConfig,
SystemInterrupt: abortSignal,
ExecutorData: data,
}
buildCredentials := &common.JobCredentials{
......
......@@ -56,7 +56,7 @@ const (
)
type Build struct {
GetBuildResponse `yaml:",inline"`
JobResponse `yaml:",inline"`
Trace BuildTrace
SystemInterrupt chan os.Signal `json:"-" yaml:"-"`
......
......@@ -41,7 +41,7 @@ func TestBuildRun(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-test",
......@@ -81,7 +81,7 @@ func TestRetryPrepare(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-retry-prepare",
......@@ -114,7 +114,7 @@ func TestPrepareFailure(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-prepare-failure",
......@@ -145,7 +145,7 @@ func TestPrepareFailureOnBuildError(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-prepare-failure-on-build-error",
......@@ -180,7 +180,7 @@ func TestRunFailure(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-run-failure",
......@@ -216,7 +216,7 @@ func TestGetSourcesRunFailure(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-get-sources-run-failure",
......@@ -254,7 +254,7 @@ func TestArtifactDownloadRunFailure(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-artifacts-run-failure",
......@@ -292,7 +292,7 @@ func TestRestoreCacheRunFailure(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-cache-run-failure",
......@@ -329,7 +329,7 @@ func TestRunWrongAttempts(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-attempt-failure",
......@@ -366,7 +366,7 @@ func TestRunSuccessOnSecondAttempt(t *testing.T) {
successfulBuild, err := GetSuccessfulBuild()
assert.NoError(t, err)
build := &Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &RunnerConfig{
RunnerSettings: RunnerSettings{
Executor: "build-run-success-second-attempt",
......
......@@ -32,12 +32,12 @@ func (m *MockNetwork) UnregisterRunner(config RunnerCredentials) bool {
return r0
}
func (m *MockNetwork) GetBuild(config RunnerConfig) (*GetBuildResponse, bool) {
func (m *MockNetwork) RequestJob(config RunnerConfig) (*JobResponse, bool) {
ret := m.Called(config)
var r0 *GetBuildResponse
var r0 *JobResponse
if ret.Get(0) != nil {
r0 = ret.Get(0).(*GetBuildResponse)
r0 = ret.Get(0).(*JobResponse)
}
r1 := ret.Get(1).(bool)
......
......@@ -48,6 +48,27 @@ type FeaturesInfo struct {
Cache bool `json:"cache"`
}
type RegisterRunnerRequest struct {
Info VersionInfo `json:"info,omitempty"`
Token string `json:"token,omitempty"`
Description string `json:"description,omitempty"`
Tags string `json:"tag_list,omitempty"`
RunUntagged bool `json:"run_untagged"`
Locked bool `json:"locked"`
}
type RegisterRunnerResponse struct {
Token string `json:"token,omitempty"`
}
type VerifyRunnerRequest struct {
Token string `json:"token,omitempty"`
}
type UnregisterRunnerRequest struct {
Token string `json:"token,omitempty"`
}
type VersionInfo struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
......@@ -58,29 +79,36 @@ type VersionInfo struct {
Features FeaturesInfo `json:"features"`
}
type GetBuildRequest struct {
type JobRequest struct {
Info VersionInfo `json:"info,omitempty"`
Token string `json:"token,omitempty"`
LastUpdate string `json:"last_update,omitempty"`
}
type BuildArtifacts struct {
type JobArtifacts struct {
Filename string `json:"filename,omitempty"`
Size int64 `json:"size,omitempty"`
}
type BuildInfo struct {
ID int `json:"id,omitempty"`
Sha string `json:"sha,omitempty"`
RefName string `json:"ref,omitempty"`
Token string `json:"token"`
Name string `json:"name"`
Stage string `json:"stage"`
Tag bool `json:"tag"`
Artifacts *BuildArtifacts `json:"artifacts_file"`
type JobInfo struct {
ID int `json:"id,omitempty"`
Sha string `json:"sha,omitempty"`
RefName string `json:"ref,omitempty"`
Token string `json:"token"`
Name string `json:"name"`
Stage string `json:"stage"`
Tag bool `json:"tag"`
Artifacts *JobArtifacts `json:"artifacts_file"`
}
type JobResponseCredentials struct {
Type string `json:"type"`
URL string `json:"url"`
Username string `json:"username"`
Password string `json:"password"`
}
type GetBuildResponse struct {
type JobResponse struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"project_id,omitempty"`
Commands string `json:"commands,omitempty"`
......@@ -96,44 +124,16 @@ type GetBuildResponse struct {
Name string `json:"name"`
Stage string `json:"stage"`
Tag bool `json:"tag"`
DependsOnBuilds []BuildInfo `json:"depends_on_builds"`
DependsOnBuilds []JobInfo `json:"depends_on_builds"`
TLSCAChain string `json:"-"`
Credentials []BuildResponseCredentials `json:"credentials,omitempty"`
Credentials []JobResponseCredentials `json:"credentials,omitempty"`
}
type BuildResponseCredentials struct {
Type string `json:"type"`
URL string `json:"url"`
Username string `json:"username"`
Password string `json:"password"`
}
func (b *GetBuildResponse) RepoCleanURL() (ret string) {
func (b *JobResponse) RepoCleanURL() (ret string) {
return url_helpers.CleanURL(b.RepoURL)
}
type RegisterRunnerRequest struct {
Info VersionInfo `json:"info,omitempty"`
Token string `json:"token,omitempty"`
Description string `json:"description,omitempty"`
Tags string `json:"tag_list,omitempty"`
RunUntagged bool `json:"run_untagged"`
Locked bool `json:"locked"`
}
type RegisterRunnerResponse struct {
Token string `json:"token,omitempty"`
}
type VerifyRunnerRequest struct {
Token string `json:"token,omitempty"`
}
type UnregisterRunnerRequest struct {
Token string `json:"token,omitempty"`
}
type UpdateBuildRequest struct {
Info VersionInfo `json:"info,omitempty"`
Token string `json:"token,omitempty"`
......@@ -180,7 +180,7 @@ type Network interface {
RegisterRunner(config RunnerCredentials, description, tags string, runUntagged, locked bool) *RegisterRunnerResponse
VerifyRunner(config RunnerCredentials) bool
UnregisterRunner(config RunnerCredentials) bool
GetBuild(config RunnerConfig) (*GetBuildResponse, bool)
RequestJob(config RunnerConfig) (*JobResponse, bool)
UpdateBuild(config RunnerConfig, id int, state BuildState, trace *string) UpdateState
PatchTrace(config RunnerConfig, buildCredentials *JobCredentials, tracePart BuildTracePatch) UpdateState
DownloadArtifacts(config JobCredentials, artifactsFile string) DownloadState
......
......@@ -12,32 +12,32 @@ const repoSHA = "6907208d755b60ebeacb2e9dfea74c92c3449a1f"
const repoBeforeSHA = "c347ca2e140aa667b968e51ed0ffe055501fe4f4"
const repoRefName = "master"
func GetSuccessfulBuild() (GetBuildResponse, error) {
func GetSuccessfulBuild() (JobResponse, error) {
return getLocalBuildResponse("echo Hello World")
}
func GetRemoteSuccessfulBuild() (GetBuildResponse, error) {
func GetRemoteSuccessfulBuild() (JobResponse, error) {
return getRemoteBuildResponse("echo Hello World")
}
func GetFailedBuild() (GetBuildResponse, error) {
func GetFailedBuild() (JobResponse, error) {
return getLocalBuildResponse("exit 1")
}
func GetRemoteFailedBuild() (GetBuildResponse, error) {
func GetRemoteFailedBuild() (JobResponse, error) {
return getRemoteBuildResponse("exit 1")
}
func GetLongRunningBuild() (GetBuildResponse, error) {
func GetLongRunningBuild() (JobResponse, error) {
return getLocalBuildResponse("sleep 3600")
}
func GetRemoteLongRunningBuild() (GetBuildResponse, error) {
func GetRemoteLongRunningBuild() (JobResponse, error) {
return getRemoteBuildResponse("sleep 3600")
}
func getRemoteBuildResponse(commands string) (response GetBuildResponse, err error) {
response = GetBuildResponse{
func getRemoteBuildResponse(commands string) (response JobResponse, err error) {
response = JobResponse{
Commands: commands,
RepoURL: repoRemoteURL,
Sha: repoSHA,
......@@ -48,13 +48,13 @@ func getRemoteBuildResponse(commands string) (response GetBuildResponse, err err
return
}
func getLocalBuildResponse(commands string) (response GetBuildResponse, err error) {
func getLocalBuildResponse(commands string) (response JobResponse, err error) {
localRepoURL, err := getLocalRepoURL()
if err != nil {
return
}
response = GetBuildResponse{
response = JobResponse{
Commands: commands,
RepoURL: localRepoURL,
Sha: repoSHA,
......
......@@ -29,7 +29,7 @@ func TestDockerCommandSuccessRun(t *testing.T) {
successfulBuild, err := common.GetRemoteSuccessfulBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......@@ -52,7 +52,7 @@ func TestDockerCommandBuildFail(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......@@ -121,7 +121,7 @@ func TestDockerCommandBuildAbort(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......@@ -157,7 +157,7 @@ func TestDockerCommandBuildCancel(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......@@ -195,7 +195,7 @@ func TestDockerCommandOutput(t *testing.T) {
successfulBuild, err := common.GetRemoteSuccessfulBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......@@ -238,7 +238,7 @@ func TestDockerPrivilegedServiceAccessingBuildsFolder(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......@@ -342,7 +342,7 @@ func testDockerVersion(t *testing.T, version string) {
successfulBuild, err := common.GetRemoteSuccessfulBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "docker",
......
......@@ -495,7 +495,7 @@ func getAuthConfigTestExecutor(t *testing.T, precreateConfigFile bool) executor
}
func addGitLabRegistryCredentials(e *executor) {
e.Build.Credentials = []common.BuildResponseCredentials{
e.Build.Credentials = []common.JobResponseCredentials{
{
Type: "registry",
URL: "registry.gitlab.tld:1234",
......
......@@ -182,7 +182,7 @@ func TestPrepare(t *testing.T) {
},
},
Build: &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
Sha: "1234567890",
Options: common.BuildOptions{
"image": "test-image",
......@@ -241,7 +241,7 @@ func TestPrepare(t *testing.T) {
},
},
Build: &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
Sha: "1234567890",
Options: common.BuildOptions{
"image": "test-image",
......@@ -303,7 +303,7 @@ func TestPrepare(t *testing.T) {
},
},
Build: &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
Sha: "1234567890",
Options: common.BuildOptions{
"image": "test-image",
......@@ -347,7 +347,7 @@ func TestPrepare(t *testing.T) {
},
},
Build: &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
Sha: "1234567890",
Options: common.BuildOptions{
"image": "test-image",
......@@ -531,7 +531,7 @@ func TestSetupBuildPod(t *testing.T) {
Config: test.RunnerConfig,
BuildShell: &common.ShellConfiguration{},
Build: &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
Variables: []common.BuildVariable{},
},
Runner: &common.RunnerConfig{},
......@@ -558,7 +558,7 @@ func TestKubernetesSuccessRun(t *testing.T) {
"image": "docker:git",
}
build := &common.Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "kubernetes",
......@@ -579,7 +579,7 @@ func TestKubernetesBuildFail(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "kubernetes",
......@@ -605,7 +605,7 @@ func TestKubernetesMissingImage(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "kubernetes",
......@@ -631,7 +631,7 @@ func TestKubernetesMissingTag(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "kubernetes",
......@@ -657,7 +657,7 @@ func TestKubernetesBuildAbort(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "kubernetes",
......@@ -694,7 +694,7 @@ func TestKubernetesBuildCancel(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "kubernetes",
......@@ -732,7 +732,7 @@ func TestOverwriteNamespaceNotMatch(t *testing.T) {
}
build := &common.Build{
GetBuildResponse: common.GetBuildResponse{
JobResponse: common.JobResponse{
Sha: "1234567890",
Options: common.BuildOptions{
"image": "test-image",
......
......@@ -39,7 +39,7 @@ func TestParallelsSuccessRun(t *testing.T) {
successfulBuild, err := common.GetRemoteSuccessfulBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "parallels",
......@@ -64,7 +64,7 @@ func TestParallelsBuildFail(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "parallels",
......@@ -136,7 +136,7 @@ func TestParallelsBuildAbort(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "parallels",
......@@ -174,7 +174,7 @@ func TestParallelsBuildCancel(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "parallels",
......
......@@ -63,7 +63,7 @@ func runBuildReturningOutput(t *testing.T, build *common.Build) (string, error)
return output, err
}
func newBuild(t *testing.T, getBuildResponse common.GetBuildResponse, shell string) (*common.Build, func()) {
func newBuild(t *testing.T, getBuildResponse common.JobResponse, shell string) (*common.Build, func()) {
dir, err := ioutil.TempDir("", "gitlab-runner-shell-executor-test")
if err != nil {
t.Fatal(err)
......@@ -72,7 +72,7 @@ func newBuild(t *testing.T, getBuildResponse common.GetBuildResponse, shell stri
t.Log("Build directory:", dir)
build := &common.Build{
GetBuildResponse: getBuildResponse,
JobResponse: getBuildResponse,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
BuildsDir: dir,
......@@ -150,7 +150,7 @@ func TestBuildWithIndexLock(t *testing.T) {
err = runBuild(t, build)
assert.NoError(t, err)
build.GetBuildResponse.AllowGitFetch = true
build.JobResponse.AllowGitFetch = true
ioutil.WriteFile(build.BuildDir+"/.git/index.lock", []byte{}, os.ModeSticky)
err = runBuild(t, build)
......
......@@ -39,7 +39,7 @@ func TestVirtualBoxSuccessRun(t *testing.T) {
successfulBuild, err := common.GetRemoteSuccessfulBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: successfulBuild,
JobResponse: successfulBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "virtualbox",
......@@ -64,7 +64,7 @@ func TestVirtualBoxBuildFail(t *testing.T) {
failedBuild, err := common.GetRemoteFailedBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: failedBuild,
JobResponse: failedBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "virtualbox",
......@@ -136,7 +136,7 @@ func TestVirtualBoxBuildAbort(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "virtualbox",
......@@ -174,7 +174,7 @@ func TestVirtualBoxBuildCancel(t *testing.T) {
longRunningBuild, err := common.GetRemoteLongRunningBuild()
assert.NoError(t, err)
build := &common.Build{
GetBuildResponse: longRunningBuild,
JobResponse: longRunningBuild,
Runner: &common.RunnerConfig{
RunnerSettings: common.RunnerSettings{
Executor: "virtualbox",
......
......@@ -165,14 +165,14 @@ func (n *GitLabClient) UnregisterRunner(runner common.RunnerCredentials) bool {
}
}
func (n *GitLabClient) GetBuild(config common.RunnerConfig) (*common.GetBuildResponse, bool) {
request := common.GetBuildRequest{
func (n *GitLabClient) RequestJob(config common.RunnerConfig) (*common.JobResponse, bool) {
request := common.JobRequest{
Info: n.getRunnerVersion(config),
Token: config.Token,
LastUpdate: n.getLastUpdate(&config.RunnerCredentials),
}
var response common.GetBuildResponse
var response common.JobResponse
result, statusText, certificates := n.doJSON(&config.RunnerCredentials, "POST", "builds/register.json", 201, &request, &response)
switch result {
......
......@@ -274,7 +274,7 @@ func TestVerifyRunner(t *testing.T) {
assert.False(t, state)
}
func testGetBuildHandler(w http.ResponseWriter, r *http.Request, t *testing.T) {
func testRequestJobHandler(w http.ResponseWriter, r *http.Request, t *testing.T) {
if r.URL.Path != "/ci/api/v1/builds/register.json" {
w.WriteHeader(404)
return
......@@ -325,9 +325,9 @@ func testGetBuildHandler(w http.ResponseWriter, r *http.Request, t *testing.T) {
w.Write(output)
}
func TestGetBuild(t *testing.T) {
func TestRequestJob(t *testing.T) {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testGetBuildHandler(w, r, t)
testRequestJobHandler(w, r, t)
}))
defer s.Close()
......@@ -354,23 +354,23 @@ func TestGetBuild(t *testing.T) {
c := NewGitLabClient()
res, ok := c.GetBuild(validToken)
res, ok := c.RequestJob(validToken)
if assert.NotNil(t, res) {
assert.NotEmpty(t, res.ID)
}
assert.True(t, ok)
assert.Empty(t, c.getLastUpdate(&noBuildsToken.RunnerCredentials), "Last-Update should not be set")
res, ok = c.GetBuild(noBuildsToken)
res, ok = c.RequestJob(noBuildsToken)
assert.Nil(t, res)
assert.True(t, ok, "If no builds, runner is healthy")
assert.Equal(t, c.getLastUpdate(&noBuildsToken.RunnerCredentials), "a nice timestamp", "Last-Update should be set")
res, ok = c.GetBuild(invalidToken)
res, ok = c.RequestJob(invalidToken)
assert.Nil(t, res)
assert.False(t, ok, "If token is invalid, the runner is unhealthy")
res, ok = c.GetBuild(brokenConfig)
res, ok = c.RequestJob(brokenConfig)
assert.Nil(t, res)
assert.False(t, ok)
}
......
......@@ -210,7 +210,7 @@ func (b *AbstractShell) cacheExtractor(w ShellWriter, options *archivingOptions,
})
}