-
Notifications
You must be signed in to change notification settings - Fork 136
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
Creating Tests for the function submitJobs #3438
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ type FailedSubmissionDetails struct { | |
|
||
func (submitService *SubmitService) SubmitJobs(jobsToSubmit []*SubmitJob) []*FailedSubmissionDetails { | ||
return submitService.submitJobs(jobsToSubmit) | ||
} | ||
} | ||
|
||
func (submitService *SubmitService) submitJobs(jobsToSubmit []*SubmitJob) []*FailedSubmissionDetails { | ||
wg := &sync.WaitGroup{} | ||
|
@@ -110,7 +110,7 @@ func (submitService *SubmitService) submitWorker(wg *sync.WaitGroup, jobsToSubmi | |
// submitPod submits a pod to k8s together with any services and ingresses bundled with the Armada job. | ||
// This function may fail partly, i.e., it may successfully create a subset of the requested objects before failing. | ||
// In case of failure, any already created objects are not cleaned up. | ||
func (submitService *SubmitService) submitPod(job *SubmitJob) (*v1.Pod, error) { | ||
func (submitService *SubmitService) submitPod(job *SubmitJob) (*v1.Pod, error) { //iska krna h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a leftover note or typo - please remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I missed it to remove |
||
pod := job.Pod | ||
// Ensure the K8SService and K8SIngress fields are populated | ||
submitService.applyExecutorSpecificIngressDetails(job) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,3 +94,30 @@ func newArbitraryError(message string) error { | |
func newArmadaErrCreateResource() error { | ||
return &armadaerrors.ErrCreateResource{} | ||
} | ||
|
||
func TestSubmitJobs(t *testing.T){ | ||
submitService := &SubmitService{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think running |
||
} | ||
job1 := &SubmitJob{} | ||
job2 := &SubmitJob{} | ||
|
||
jobsToSubmit := []*SubmitJob{job1, job2} | ||
|
||
submitJobsChannel := make(chan *SubmitJob) | ||
failedJobsChannel := make(chan *FailedSubmissionDetails, len(jobsToSubmit)) | ||
|
||
assert.NotNil(t, submitJobsChannel, "Failed to create submitJobsChannel") | ||
assert.NotNil(t, failedJobsChannel, "Failed to create failedJobsChannel") | ||
|
||
submitService.submitWorker = func(wg *sync.WaitGroup, submitJobs chan *SubmitJob, failedJobs chan *FailedSubmissionDetails) { | ||
for job := range submitJobs { | ||
failedJobs <- &FailedSubmissionDetails{ | ||
} | ||
} | ||
wg.Done() | ||
} | ||
failedJobs := submitService.submitJobs(jobsToSubmit) | ||
|
||
assert.NotNil(t, failedJobs, "Function did not returned slice of FailedSubmissionDetails") | ||
assert.Len(t, failedJobs, len(jobsToSubmit), "Unexpected length of failedJobs") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this change - there shouldn't be extra whitespace at the end of lines. (I think running
golangci-lint
will warn about things like this, and usinggo fmt file_xxx.go
will fix it for you.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @richscott I will make these changes