Skip to content

Commit

Permalink
DL binary client timeout in ms
Browse files Browse the repository at this point in the history
  • Loading branch information
angelini committed Mar 20, 2024
1 parent e157a6f commit 6f35809
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions js/spec/binary-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ describe("binary client operations", () => {
});

it("can gc random-projects and return the count cleaned up", async () => {
const result = await binaryClient.gcRandomProjects(90, 2, -1, { timeout: 90 });
const result = await binaryClient.gcRandomProjects(90, 2, -1, { timeout: 1_000 });

expect(JSON.stringify(result)).toMatch('{"count":0}');
expect(result.count).toStrictEqual(0);
});

it("can gc a specific project and return the count cleaned up", async () => {
const result = await binaryClient.gcProject(1, 2, -1, { timeout: 90 });
const result = await binaryClient.gcProject(1, 2, -1, { timeout: 1_000 });

expect(JSON.stringify(result)).toMatch('{"count":0}');
expect(result.count).toStrictEqual(0);
});

it("can gc contents and successfully return the count of contents cleaned up", async () => {
const result = await binaryClient.gcContents(90, { timeout: 90 });
const result = await binaryClient.gcContents(90, { timeout: 1_000 });

expect(JSON.stringify(result)).toMatch('{"count":0}');
expect(result.count).toStrictEqual(0);
Expand All @@ -139,7 +139,7 @@ describe("binary client operations", () => {
await grpcClient.newProject(project, []);

const stream = grpcClient.updateObjects(project);
for (let i = 0; i < 1000; i++) {
for (let i = 0; i < 30; i++) {
const content = encodeContent(crypto.randomBytes(512 * 1024).toString("hex"));
await stream.send({
path: `hello-${i}.txt`,
Expand All @@ -152,9 +152,9 @@ describe("binary client operations", () => {
await stream.complete();

const dir = tmpdir();
const rebuildPromise = binaryClient.rebuild(project, null, dir, { timeout: 1 });
const rebuildPromise = binaryClient.rebuild(project, null, dir, { timeout: 25 });
await expect(rebuildPromise).rejects.toThrow(/context deadline exceeded/);
}, 20_000);
});
});

describe("Gadget file match tests", () => {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewClientCommand() *cobra.Command {
otelContext string
host string
port uint16
timeout uint16
timeout uint
headlessHost string
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func NewClientCommand() *cobra.Command {

fmt.Fprintf(os.Stderr, "timeout: %v\n", timeout)
if timeout != 0 {
ctx, cancel = context.WithTimeout(cmd.Context(), time.Duration(timeout)*time.Second)
ctx, cancel = context.WithTimeout(cmd.Context(), time.Duration(timeout)*time.Millisecond)
fmt.Fprintf(os.Stderr, "duration: %v\n", time.Duration(timeout)*time.Second)
}

Expand Down Expand Up @@ -115,7 +115,7 @@ func NewClientCommand() *cobra.Command {
flags.StringVar(&otelContext, "otel-context", "", "Open Telemetry context")
flags.StringVar(&host, "host", "", "GRPC server hostname")
flags.Uint16Var(&port, "port", 5051, "GRPC server port")
flags.Uint16Var(&timeout, "timeout", 0, "GRPC client timeout")
flags.UintVar(&timeout, "timeout", 0, "GRPC client timeout (ms)")
flags.StringVar(&headlessHost, "headless-host", "", "Alternative headless hostname to use for round robin connections")

cmd.AddCommand(NewCmdGet())
Expand Down

0 comments on commit 6f35809

Please sign in to comment.