Skip to content

Commit

Permalink
Shorten delay on simulated Armada events.
Browse files Browse the repository at this point in the history
Also, create struct for passing query params in preparation
for passing via a channel.
  • Loading branch information
richscott committed Aug 24, 2023
1 parent f328cdc commit cb6d5f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 4 additions & 4 deletions testsuite/performance/jobservice/fakearmada/event_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
20 changes: 13 additions & 7 deletions testsuite/performance/jobservice/jsloadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand All @@ -63,20 +70,19 @@ 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 {
fmt.Println(err.Error())
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
}

0 comments on commit cb6d5f7

Please sign in to comment.