From cb6d5f78f349023831f05983a9b47555d8427cf9 Mon Sep 17 00:00:00 2001 From: Rich Scott Date: Wed, 23 Aug 2023 19:59:11 -0600 Subject: [PATCH] Shorten delay on simulated Armada events. Also, create struct for passing query params in preparation for passing via a channel. --- .../jobservice/fakearmada/event_server.go | 8 ++++---- .../performance/jobservice/jsloadtest.go | 20 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/testsuite/performance/jobservice/fakearmada/event_server.go b/testsuite/performance/jobservice/fakearmada/event_server.go index a9e12f6490c..bbc0ab70df8 100644 --- a/testsuite/performance/jobservice/fakearmada/event_server.go +++ b/testsuite/performance/jobservice/fakearmada/event_server.go @@ -82,7 +82,7 @@ var messageScript = []*scriptedMessage{ }, }, { // Queued - Delay: time.Duration(time.Millisecond * 200), + Delay: time.Duration(time.Millisecond * 50), MessageFunc: func(request *api.JobSetRequest, jobSetId, jobId int) *api.EventMessage { jobIdStr := fmt.Sprintf("%d", jobId) jobSetIdStr := fmt.Sprintf("%d", jobSetId) @@ -101,7 +101,7 @@ var messageScript = []*scriptedMessage{ }, }, { // Running - Delay: time.Duration(time.Millisecond * 500), + Delay: time.Duration(time.Millisecond * 100), MessageFunc: func(request *api.JobSetRequest, jobSetId, jobId int) *api.EventMessage { jobIdStr := fmt.Sprintf("%d", jobId) jobSetIdStr := fmt.Sprintf("%d", jobSetId) @@ -126,7 +126,7 @@ var messageScript = []*scriptedMessage{ }, }, { // Success - Delay: time.Duration(time.Second * 5), + Delay: time.Duration(time.Second * 1), MessageFunc: func(request *api.JobSetRequest, jobSetId, jobId int) *api.EventMessage { jobIdStr := fmt.Sprintf("%d", jobId) jobSetIdStr := fmt.Sprintf("%d", jobSetId) @@ -164,7 +164,7 @@ func (s *PerformanceTestEventServer) serveSimulatedEvents(request *api.JobSetReq for _, message := range messageScript { time.Sleep(message.Delay) err := stream.Send(&api.EventStreamMessage{ - Id: fmt.Sprintf("%d-%d", jobSetId, jobId), + Id: fmt.Sprintf("%d", jobSetId), Message: message.MessageFunc(request, jobSetId, jobId), }) if err != nil { diff --git a/testsuite/performance/jobservice/jsloadtest.go b/testsuite/performance/jobservice/jsloadtest.go index fe83494dc86..76afe5b2e5b 100644 --- a/testsuite/performance/jobservice/jsloadtest.go +++ b/testsuite/performance/jobservice/jsloadtest.go @@ -21,6 +21,12 @@ var ( numJobSets = flag.Int("jobsets", 50, "number of jobsets") ) +type JSQuery struct { + JobSetId int + JobId int + Prefix int +} + func init() { rng = rand.New(rand.NewSource(time.Now().UnixNano())) flag.Parse() @@ -50,9 +56,10 @@ func main() { for jobSetId := 0; jobSetId < *numJobSets; jobSetId++ { for jobId := 0; jobId < *numJobs; jobId++ { - fmt.Printf("querying jobset %d job %d\n", jobSetId, jobId) + // fmt.Printf("querying jobset %d job %d\n", jobSetId, jobId) go func(jobSetId, jobId int) { - err := queryJobStatus(ctx, conn, jobSetId, jobId, prefix) + query := JSQuery{JobSetId: jobSetId, JobId: jobId, Prefix: prefix} + err := queryJobStatus(ctx, conn, query) if err != nil { fmt.Printf("Error querying job status: %v\n", err) } @@ -63,13 +70,12 @@ func main() { wg.Wait() } -func queryJobStatus(ctx context.Context, conn *grpc.ClientConn, jobSetId, jobId, prefix int) error { +func queryJobStatus(ctx context.Context, conn *grpc.ClientConn, query JSQuery) error { client := jsgrpc.NewJobServiceClient(conn) resp, err := client.GetJobStatus(ctx, &jsgrpc.JobServiceRequest{ - JobId: fmt.Sprintf("%d", jobId), - // JobSetId: fmt.Sprintf("%d_new_fake_job_set_id_%d", prefix, jobSetId), - JobSetId: fmt.Sprintf("%d", jobSetId), + JobId: fmt.Sprintf("%d", query.JobId), + JobSetId: fmt.Sprintf("%d", query.JobSetId), Queue: "fake_queue", }) if err != nil { @@ -77,6 +83,6 @@ func queryJobStatus(ctx context.Context, conn *grpc.ClientConn, jobSetId, jobId, return err } - fmt.Printf("%s - %d\n", resp.State.String(), jobSetId) + fmt.Printf("%s - Job Set %d, Job %d\n", resp.State.String(), query.JobSetId, query.JobId) return nil }