Skip to content
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

[JobRouter] Fix reclassify #37810

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ public virtual async Task<Response> ReclassifyJobAsync(
{
var response = await RestClient.ReclassifyJobActionAsync(
id: jobId,
new ReclassifyJobRequest(),
cancellationToken: cancellationToken).ConfigureAwait(false);
return response.GetRawResponse();
}
Expand Down Expand Up @@ -579,6 +580,7 @@ public virtual Response ReclassifyJob(
{
var response = RestClient.ReclassifyJobAction(
id: jobId,
new ReclassifyJobRequest(),
cancellationToken: cancellationToken);
return response.GetRawResponse();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Azure.Core;

namespace Azure.Communication.JobRouter
{
/// <summary>
/// An assignment of a worker to a queue.
/// </summary>
internal class ReclassifyJobRequest : IUtf8JsonSerializable
{
/// <summary>
/// Write empty object.
/// </summary>
/// <param name="writer"></param>
void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,39 @@ public async Task CreateJobWithScheduleAndSuspendMode()
Assert.IsNull(createJob1.MatchingMode.QueueAndMatchMode);
}

[Test]
public async Task ReclassifyJob()
{
JobRouterClient routerClient = CreateRouterClientWithConnectionString();
JobRouterAdministrationClient routerAdminClient = CreateRouterAdministrationClientWithConnectionString();
var channelId = GenerateUniqueId($"{nameof(ReclassifyJob)}-Channel");

// Setup queue
var createQueueResponse = await CreateQueueAsync(nameof(ReclassifyJob));
var createQueue = createQueueResponse.Value;

var classificationPolicy = await routerAdminClient.CreateClassificationPolicyAsync(
new CreateClassificationPolicyOptions(GenerateUniqueId($"{IdPrefix}{nameof(ReclassifyJob)}-policy"))
{
PrioritizationRule = new StaticRouterRule(new LabelValue(1))
});
AddForCleanup(new Task(async () => await routerAdminClient.DeleteClassificationPolicyAsync(classificationPolicy.Value.Id)));

// Create 1 job
var jobId1 = GenerateUniqueId($"{IdPrefix}{nameof(ReclassifyJob)}-job");
var createJob1Response = await routerClient.CreateJobWithClassificationPolicyAsync(
new CreateJobWithClassificationPolicyOptions(jobId1, channelId, classificationPolicy.Value.Id)
{
QueueId = createQueue.Id
});
var createJob1 = createJob1Response.Value;
AddForCleanup(new Task(async () => await routerClient.DeleteJobAsync(createJob1.Id)));

await routerClient.ReclassifyJobAsync(jobId1);

Assert.AreEqual(createJob1.QueueId, createQueue.Id);
}

#endregion Job Tests

}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading