Renaming AuroraURL to not be exported. Added a bad payload timeout test. Refactored good payload timeout test.
This commit is contained in:
parent
19aacbb586
commit
9ad2dde3e1
1 changed files with 46 additions and 19 deletions
|
@ -35,13 +35,13 @@ var r realis.Realis
|
||||||
var monitor *realis.Monitor
|
var monitor *realis.Monitor
|
||||||
var thermosPayload []byte
|
var thermosPayload []byte
|
||||||
|
|
||||||
const AuroraURL = "http://192.168.33.7:8081"
|
const auroraURL = "http://192.168.33.7:8081"
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// New configuration to connect to docker container
|
// New configuration to connect to docker container
|
||||||
r, err = realis.NewRealisClient(realis.SchedulerUrl(AuroraURL),
|
r, err = realis.NewRealisClient(realis.SchedulerUrl(auroraURL),
|
||||||
realis.BasicAuth("aurora", "secret"),
|
realis.BasicAuth("aurora", "secret"),
|
||||||
realis.TimeoutMS(20000))
|
realis.TimeoutMS(20000))
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func TestNonExistentEndpoint(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestThriftBinary(t *testing.T) {
|
func TestThriftBinary(t *testing.T) {
|
||||||
r, err := realis.NewRealisClient(realis.SchedulerUrl(AuroraURL),
|
r, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL),
|
||||||
realis.BasicAuth("aurora", "secret"),
|
realis.BasicAuth("aurora", "secret"),
|
||||||
realis.TimeoutMS(20000),
|
realis.TimeoutMS(20000),
|
||||||
realis.ThriftBinary())
|
realis.ThriftBinary())
|
||||||
|
@ -117,7 +117,7 @@ func TestThriftBinary(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestThriftJSON(t *testing.T) {
|
func TestThriftJSON(t *testing.T) {
|
||||||
r, err := realis.NewRealisClient(realis.SchedulerUrl(AuroraURL),
|
r, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL),
|
||||||
realis.BasicAuth("aurora", "secret"),
|
realis.BasicAuth("aurora", "secret"),
|
||||||
realis.TimeoutMS(20000),
|
realis.TimeoutMS(20000),
|
||||||
realis.ThriftJSON())
|
realis.ThriftJSON())
|
||||||
|
@ -139,7 +139,7 @@ func TestThriftJSON(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoopLogger(t *testing.T) {
|
func TestNoopLogger(t *testing.T) {
|
||||||
r, err := realis.NewRealisClient(realis.SchedulerUrl(AuroraURL),
|
r, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL),
|
||||||
realis.BasicAuth("aurora", "secret"),
|
realis.BasicAuth("aurora", "secret"),
|
||||||
realis.SetLogger(realis.NoopLogger{}))
|
realis.SetLogger(realis.NoopLogger{}))
|
||||||
|
|
||||||
|
@ -488,33 +488,60 @@ func TestRealisClient_CreateService(t *testing.T) {
|
||||||
success, err := monitor.Instances(job.JobKey(), 0, 1, 50)
|
success, err := monitor.Instances(job.JobKey(), 0, 1, 50)
|
||||||
assert.True(t, success)
|
assert.True(t, success)
|
||||||
|
|
||||||
|
// Create a client which will timeout and close the connection before receiving an answer
|
||||||
|
timeoutClient, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL),
|
||||||
|
realis.BasicAuth("aurora", "secret"),
|
||||||
|
realis.TimeoutMS(10))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer timeoutClient.Close()
|
||||||
|
|
||||||
// Test case where http connection timeouts out.
|
// Test case where http connection timeouts out.
|
||||||
t.Run("TimeoutError", func(t *testing.T) {
|
t.Run("TimeoutError", func(t *testing.T) {
|
||||||
timeoutClient, err := realis.NewRealisClient(realis.SchedulerUrl(AuroraURL),
|
job.Name("createService_timeout")
|
||||||
realis.BasicAuth("aurora", "secret"),
|
|
||||||
realis.TimeoutMS(20))
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
defer timeoutClient.Close()
|
|
||||||
|
|
||||||
// Make sure a timedout error was returned
|
// Make sure a timedout error was returned
|
||||||
_, _, err = timeoutClient.CreateService(job, settings)
|
_, _, err = timeoutClient.CreateService(job, settings)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.True(t, realis.IsTimeout(err))
|
assert.True(t, realis.IsTimeout(err))
|
||||||
|
|
||||||
summary, err := r.GetJobUpdateSummaries(&aurora.JobUpdateQuery{Role: &job.JobKey().Role, JobKey: job.JobKey()})
|
updateReceivedQuery := aurora.JobUpdateQuery{
|
||||||
|
Role: &job.JobKey().Role,
|
||||||
|
JobKey: job.JobKey(),
|
||||||
|
UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES,
|
||||||
|
Limit: 1}
|
||||||
|
|
||||||
|
updateSummaries, err := monitor.JobUpdateQuery(updateReceivedQuery, time.Second*1, time.Second*50)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// If the call went through, then clean up
|
assert.Len(t, updateSummaries, 1)
|
||||||
if len(summary.GetResult_().GetGetJobUpdateSummariesResult_().GetUpdateSummaries()) > 1 {
|
|
||||||
key := summary.GetResult_().GetGetJobUpdateSummariesResult_().GetUpdateSummaries()[0].GetKey()
|
|
||||||
|
|
||||||
_, err = r.AbortJobUpdate(*key, "Cleaning up")
|
_, err = r.AbortJobUpdate(*updateSummaries[0].Key, "Cleaning up")
|
||||||
_, err = r.KillJob(job.JobKey())
|
_, err = r.KillJob(job.JobKey())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Test case where http connection timeouts out.
|
||||||
|
t.Run("TimeoutError_BadPayload", func(t *testing.T) {
|
||||||
|
// Illegal payload
|
||||||
|
job.InstanceCount(-1)
|
||||||
|
job.Name("createService_timeout_bad_payload")
|
||||||
|
|
||||||
|
// Make sure a timedout error was returned
|
||||||
|
_, _, err = timeoutClient.CreateService(job, settings)
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.True(t, realis.IsTimeout(err))
|
||||||
|
|
||||||
|
summary, err := r.GetJobUpdateSummaries(
|
||||||
|
&aurora.JobUpdateQuery{
|
||||||
|
Role: &job.JobKey().Role,
|
||||||
|
JobKey: job.JobKey(),
|
||||||
|
UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// Payload should have been rejected, no update should exist
|
||||||
|
assert.Len(t, summary.GetResult_().GetGetJobUpdateSummariesResult_().GetUpdateSummaries(), 0)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test configuring an executor that doesn't exist for CreateJob API
|
// Test configuring an executor that doesn't exist for CreateJob API
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue