From c8c965f4e419f823d3abf4344a86f122c774bd19 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Wed, 14 Aug 2024 17:53:18 -0700 Subject: [PATCH 01/17] add support for the get_vcpu_ms hostcall --- compute_runtime/compute_runtime.go | 22 ++++++++++++++ compute_runtime/doc.go | 5 ++++ integration_tests/compute_runtime/fastly.toml | 11 +++++++ .../compute_runtime/main_test.go | 27 +++++++++++++++++ internal/abi/fastly/compute_runtime_guest.go | 30 +++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 compute_runtime/compute_runtime.go create mode 100644 compute_runtime/doc.go create mode 100644 integration_tests/compute_runtime/fastly.toml create mode 100644 integration_tests/compute_runtime/main_test.go create mode 100644 internal/abi/fastly/compute_runtime_guest.go diff --git a/compute_runtime/compute_runtime.go b/compute_runtime/compute_runtime.go new file mode 100644 index 0000000..0c707a3 --- /dev/null +++ b/compute_runtime/compute_runtime.go @@ -0,0 +1,22 @@ +// Copyright 2024 Fastly, Inc. +// +package compute_runtime + +import ( + "time" + + "github.com/fastly/compute-sdk-go/internal/abi/fastly" +) + +func GetVCPUTime() (time.Duration, error) { + milliseconds, err := fastly.GetVCPUMilliseconds() + + if err != nil { + return 0, err + } + + var result time.Duration + result = time.Duration(milliseconds) * time.Millisecond + + return result, nil +} diff --git a/compute_runtime/doc.go b/compute_runtime/doc.go new file mode 100644 index 0000000..387962d --- /dev/null +++ b/compute_runtime/doc.go @@ -0,0 +1,5 @@ +// Copyright 2024 Fastly, Inc. +// +// Package compute_runtime provides ways to reflect on the operation of the +// compute runtime in which your application is operating. +package compute_runtime diff --git a/integration_tests/compute_runtime/fastly.toml b/integration_tests/compute_runtime/fastly.toml new file mode 100644 index 0000000..011c87b --- /dev/null +++ b/integration_tests/compute_runtime/fastly.toml @@ -0,0 +1,11 @@ +# This file describes a Fastly Compute package. To learn more visit: +# https://developer.fastly.com/reference/fastly-toml/ + +authors = ["oss@fastly.com"] +description = "" +language = "other" +manifest_version = 2 +name = "compute_runtime" +service_id = "" + +[local_server] diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go new file mode 100644 index 0000000..b16ed1b --- /dev/null +++ b/integration_tests/compute_runtime/main_test.go @@ -0,0 +1,27 @@ +// Copyright 2024 Fastly, Inc. +package main + +import ( + "testing" + "time" + + "github.com/fastly/compute-sdk-go/compute_runtime" +) + +func TestGetVcpuMs(t *testing.T) { + start, err := compute_runtime.GetVCPUTime() + if err != nil { + t.Errorf("Couldn't get starting vcpu time") + } + + time.Sleep(5 * time.Second) + + end, err := compute_runtime.GetVCPUTime() + if err != nil { + t.Errorf("Couldn't get ending vcpu time") + } + + if end - start > time.Second { + t.Errorf("Sleeping shouldn't count as vcpu time!") + } +} diff --git a/internal/abi/fastly/compute_runtime_guest.go b/internal/abi/fastly/compute_runtime_guest.go new file mode 100644 index 0000000..da26bd0 --- /dev/null +++ b/internal/abi/fastly/compute_runtime_guest.go @@ -0,0 +1,30 @@ +//go:build ((tinygo.wasm && wasi) || wasip1) && !nofastlyhostcalls +// Copyright 2024 Fastly, Inc. +package fastly + +import ( + "github.com/fastly/compute-sdk-go/internal/abi/prim" +) + +// witx: +// (module $fastly_compute_runtime +// (@interface func (export "get_vcpu_ms") +// (result $err (expected $vcpu_ms (error $fastly_status))) +// ) +// ) +// +//go:wasmimport fastly_compute_runtime get_vcpu_ms +//go:noescape +func fastlyGetVCPUMs(prim.Pointer[prim.U64]) FastlyStatus + +func GetVCPUMilliseconds() (uint64, error) { + var milliseconds prim.U64 + + err := fastlyGetVCPUMs(prim.ToPointer(&milliseconds)).toError() + + if err != nil { + return 0, err + } + + return uint64(milliseconds), nil +} From f04021b8eaf93cc98147d1dce3035c31211b290d Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 14:58:21 -0700 Subject: [PATCH 02/17] add a test to make sure that vcpu time advances --- .../compute_runtime/main_test.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index b16ed1b..fd4ab6b 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -24,4 +24,27 @@ func TestGetVcpuMs(t *testing.T) { if end - start > time.Second { t.Errorf("Sleeping shouldn't count as vcpu time!") } + + now, err := compute_runtime.GetVCPUTime() + if err != nil { + t.Errorf("Couldn't get starting vcpu time") + } + + var counter uint64 + var next time.Duration + + counter = 0 + next = now + for now == next { + new_next, err := compute_runtime.GetVCPUTime() + if err != nil { + t.Errorf("Couldn't get starting vcpu time") + } + next = new_next + counter += 1 + } + + if counter == 0 { + t.Errorf("It should take at least one loop to advance vcpu time") + } } From ff3c1f585fb8d3f5fdb347eda46a3f46757722ab Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 16:33:02 -0700 Subject: [PATCH 03/17] add a blank line after the copyright claims --- compute_runtime/compute_runtime.go | 3 ++- compute_runtime/doc.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compute_runtime/compute_runtime.go b/compute_runtime/compute_runtime.go index 0c707a3..5277541 100644 --- a/compute_runtime/compute_runtime.go +++ b/compute_runtime/compute_runtime.go @@ -1,5 +1,6 @@ // Copyright 2024 Fastly, Inc. -// + +// Useful functions for interacting with the compute instance runtime. package compute_runtime import ( diff --git a/compute_runtime/doc.go b/compute_runtime/doc.go index 387962d..2199e8b 100644 --- a/compute_runtime/doc.go +++ b/compute_runtime/doc.go @@ -1,5 +1,5 @@ // Copyright 2024 Fastly, Inc. -// + // Package compute_runtime provides ways to reflect on the operation of the // compute runtime in which your application is operating. package compute_runtime From 31ff51dba9fe8c9c5015d0497cf59d7212acf981 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 16:40:26 -0700 Subject: [PATCH 04/17] Add some more documentation --- compute_runtime/compute_runtime.go | 14 ++++++++++++++ internal/abi/fastly/compute_runtime_guest.go | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/compute_runtime/compute_runtime.go b/compute_runtime/compute_runtime.go index 5277541..edbdafd 100644 --- a/compute_runtime/compute_runtime.go +++ b/compute_runtime/compute_runtime.go @@ -9,6 +9,20 @@ import ( "github.com/fastly/compute-sdk-go/internal/abi/fastly" ) +// Get the amount of time taken on the vCPU. +// +// The resulting time is millisecond-accurate, but we recommend against +// comparing the absolute values returned across different runs (or builds) +// of the program. +// +// Because compute guests can run on a variety of different platforms, +// you should not necessarily expect these values to converge across +// different sessions. Instead, we strongly recommend using this value +// to look at the relative cost of various operations in your code base, +// by taking the time before and after a particular operation and then +// dividing this by the total amount of vCPU time your program takes. +// The resulting percentage should be relatively stable across different +// platforms, and useful in doing A/B testing. func GetVCPUTime() (time.Duration, error) { milliseconds, err := fastly.GetVCPUMilliseconds() diff --git a/internal/abi/fastly/compute_runtime_guest.go b/internal/abi/fastly/compute_runtime_guest.go index da26bd0..52c509a 100644 --- a/internal/abi/fastly/compute_runtime_guest.go +++ b/internal/abi/fastly/compute_runtime_guest.go @@ -17,6 +17,17 @@ import ( //go:noescape func fastlyGetVCPUMs(prim.Pointer[prim.U64]) FastlyStatus +// Return the number of milliseconds spent on the CPU for the current +// session. +// +// Because compute guests can run on a variety of different platforms, +// you should not necessarily expect these values to converge across +// different sessions. Instead, we strongly recommend using this value +// to look at the relative cost of various operations in your code base, +// by taking the time before and after a particular operation and then +// dividing this by the total amount of vCPU time your program takes. +// The resulting percentage should be relatively stable across different +// platforms, and useful in doing A/B testing. func GetVCPUMilliseconds() (uint64, error) { var milliseconds prim.U64 From 7af3237d7740b093f208dbdf5ef4eb9a781056dc Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 16:42:22 -0700 Subject: [PATCH 05/17] Also add the call to hostcalls_noguest.go --- internal/abi/fastly/hostcalls_noguest.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/abi/fastly/hostcalls_noguest.go b/internal/abi/fastly/hostcalls_noguest.go index bb03ea1..2e9072b 100644 --- a/internal/abi/fastly/hostcalls_noguest.go +++ b/internal/abi/fastly/hostcalls_noguest.go @@ -512,3 +512,7 @@ func PenaltyBoxAdd(penaltyBox, entry string, ttl time.Duration) error { func PenaltyBoxHas(penaltyBox, entry string) (bool, error) { return false, fmt.Errorf("not implemented") } + +func GetVCPUMilliseconds() (uint64, error) { + return false, fmt.Errorf("not implemented") +} From fe4fd75c22a5f23398ec6b81e398f793d59facfc Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 16:45:47 -0700 Subject: [PATCH 06/17] compute_runtime -> compute --- compute_runtime/compute_runtime.go => compute/compute.go | 2 +- {compute_runtime => compute}/doc.go | 2 +- integration_tests/compute_runtime/main_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename compute_runtime/compute_runtime.go => compute/compute.go (98%) rename {compute_runtime => compute}/doc.go (87%) diff --git a/compute_runtime/compute_runtime.go b/compute/compute.go similarity index 98% rename from compute_runtime/compute_runtime.go rename to compute/compute.go index edbdafd..40e4f4f 100644 --- a/compute_runtime/compute_runtime.go +++ b/compute/compute.go @@ -1,7 +1,7 @@ // Copyright 2024 Fastly, Inc. // Useful functions for interacting with the compute instance runtime. -package compute_runtime +package compute import ( "time" diff --git a/compute_runtime/doc.go b/compute/doc.go similarity index 87% rename from compute_runtime/doc.go rename to compute/doc.go index 2199e8b..02b1600 100644 --- a/compute_runtime/doc.go +++ b/compute/doc.go @@ -2,4 +2,4 @@ // Package compute_runtime provides ways to reflect on the operation of the // compute runtime in which your application is operating. -package compute_runtime +package compute diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index fd4ab6b..085b69e 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/fastly/compute-sdk-go/compute_runtime" + "github.com/fastly/compute-sdk-go/compute" ) func TestGetVcpuMs(t *testing.T) { From d1b7f1ad7079f1a5d4a02219e874f03ff41918cf Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 16:49:27 -0700 Subject: [PATCH 07/17] compute_runtime -> compute, part 2 --- integration_tests/compute_runtime/main_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index 085b69e..d1c8a05 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -9,14 +9,14 @@ import ( ) func TestGetVcpuMs(t *testing.T) { - start, err := compute_runtime.GetVCPUTime() + start, err := compute.GetVCPUTime() if err != nil { t.Errorf("Couldn't get starting vcpu time") } time.Sleep(5 * time.Second) - end, err := compute_runtime.GetVCPUTime() + end, err := compute.GetVCPUTime() if err != nil { t.Errorf("Couldn't get ending vcpu time") } @@ -25,7 +25,7 @@ func TestGetVcpuMs(t *testing.T) { t.Errorf("Sleeping shouldn't count as vcpu time!") } - now, err := compute_runtime.GetVCPUTime() + now, err := compute.GetVCPUTime() if err != nil { t.Errorf("Couldn't get starting vcpu time") } @@ -36,7 +36,7 @@ func TestGetVcpuMs(t *testing.T) { counter = 0 next = now for now == next { - new_next, err := compute_runtime.GetVCPUTime() + new_next, err := compute.GetVCPUTime() if err != nil { t.Errorf("Couldn't get starting vcpu time") } From 23fbf02dcef86ed657c93f4a9cb3415bdce48e83 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 17:17:49 -0700 Subject: [PATCH 08/17] use the right return value in the stub --- internal/abi/fastly/hostcalls_noguest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/abi/fastly/hostcalls_noguest.go b/internal/abi/fastly/hostcalls_noguest.go index 2e9072b..253d057 100644 --- a/internal/abi/fastly/hostcalls_noguest.go +++ b/internal/abi/fastly/hostcalls_noguest.go @@ -514,5 +514,5 @@ func PenaltyBoxHas(penaltyBox, entry string) (bool, error) { } func GetVCPUMilliseconds() (uint64, error) { - return false, fmt.Errorf("not implemented") + return 0, fmt.Errorf("not implemented") } From d5e74c601ef791157c26bd2dde64eb2deab55105 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 16 Aug 2024 17:25:19 -0700 Subject: [PATCH 09/17] make staticcheck happy by combining the Duration declaration and definition. --- compute/compute.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compute/compute.go b/compute/compute.go index 40e4f4f..e2a86c1 100644 --- a/compute/compute.go +++ b/compute/compute.go @@ -30,8 +30,7 @@ func GetVCPUTime() (time.Duration, error) { return 0, err } - var result time.Duration - result = time.Duration(milliseconds) * time.Millisecond + var result time.Duration = time.Duration(milliseconds) * time.Millisecond return result, nil } From 1a6caf0fca0cf260916c7304475207d29d1a5505 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 12:26:06 -0700 Subject: [PATCH 10/17] Update compute/compute.go Co-authored-by: Federico G. Schwindt --- compute/compute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/compute.go b/compute/compute.go index e2a86c1..aae0e6d 100644 --- a/compute/compute.go +++ b/compute/compute.go @@ -30,7 +30,7 @@ func GetVCPUTime() (time.Duration, error) { return 0, err } - var result time.Duration = time.Duration(milliseconds) * time.Millisecond + result := time.Duration(milliseconds) * time.Millisecond return result, nil } From 22cbc93460aed10762e5f726ed8adee3f5c0e0f9 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 20:13:02 +0000 Subject: [PATCH 11/17] I think this is the merge of two suggestions. --- integration_tests/compute_runtime/main_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index d1c8a05..245481d 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -31,10 +31,9 @@ func TestGetVcpuMs(t *testing.T) { } var counter uint64 - var next time.Duration counter = 0 - next = now + next := now for now == next { new_next, err := compute.GetVCPUTime() if err != nil { From 839b205f22b1710bccfed4d98ca10e9f3a38ed9a Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 20:19:50 +0000 Subject: [PATCH 12/17] Shorten the delay and test for sleep not causing vcpu time. --- integration_tests/compute_runtime/main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index 245481d..0785339 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -14,14 +14,14 @@ func TestGetVcpuMs(t *testing.T) { t.Errorf("Couldn't get starting vcpu time") } - time.Sleep(5 * time.Second) + time.Sleep(2 * time.Second) end, err := compute.GetVCPUTime() if err != nil { t.Errorf("Couldn't get ending vcpu time") } - if end - start > time.Second { + if end - start > (500 * time.Millisecond) { t.Errorf("Sleeping shouldn't count as vcpu time!") } From c06a439b99dfcc8140f896a39baed1bafa78c158 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 20:24:38 +0000 Subject: [PATCH 13/17] Clearly separate the error messages. --- integration_tests/compute_runtime/main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index 0785339..4a414ac 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -27,7 +27,7 @@ func TestGetVcpuMs(t *testing.T) { now, err := compute.GetVCPUTime() if err != nil { - t.Errorf("Couldn't get starting vcpu time") + t.Errorf("Couldn't get starting vcpu time (part 2)") } var counter uint64 @@ -37,7 +37,7 @@ func TestGetVcpuMs(t *testing.T) { for now == next { new_next, err := compute.GetVCPUTime() if err != nil { - t.Errorf("Couldn't get starting vcpu time") + t.Errorf("Couldn't get part 2's recheck of vcpu time") } next = new_next counter += 1 From 0db75549e24e7742274281195aee4dff35824c4b Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 20:49:25 +0000 Subject: [PATCH 14/17] Only run the get_vcpu test if we're running with hostcalls --- integration_tests/compute_runtime/main_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index 4a414ac..e1f8e54 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -1,3 +1,5 @@ +//go:build ((tinygo.wasm && wasi) || wasip1) && !nofastlyhostcalls + // Copyright 2024 Fastly, Inc. package main From 0f61e8ca28b88387d63858defd3de6b956c14636 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 20:49:48 +0000 Subject: [PATCH 15/17] Formatting. --- compute/compute.go | 16 ++++++------- internal/abi/fastly/compute_runtime_guest.go | 24 ++++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/compute/compute.go b/compute/compute.go index aae0e6d..82c761b 100644 --- a/compute/compute.go +++ b/compute/compute.go @@ -4,9 +4,9 @@ package compute import ( - "time" + "time" - "github.com/fastly/compute-sdk-go/internal/abi/fastly" + "github.com/fastly/compute-sdk-go/internal/abi/fastly" ) // Get the amount of time taken on the vCPU. @@ -24,13 +24,13 @@ import ( // The resulting percentage should be relatively stable across different // platforms, and useful in doing A/B testing. func GetVCPUTime() (time.Duration, error) { - milliseconds, err := fastly.GetVCPUMilliseconds() + milliseconds, err := fastly.GetVCPUMilliseconds() - if err != nil { - return 0, err - } + if err != nil { + return 0, err + } - result := time.Duration(milliseconds) * time.Millisecond + result := time.Duration(milliseconds) * time.Millisecond - return result, nil + return result, nil } diff --git a/internal/abi/fastly/compute_runtime_guest.go b/internal/abi/fastly/compute_runtime_guest.go index 52c509a..8e93118 100644 --- a/internal/abi/fastly/compute_runtime_guest.go +++ b/internal/abi/fastly/compute_runtime_guest.go @@ -1,16 +1,20 @@ //go:build ((tinygo.wasm && wasi) || wasip1) && !nofastlyhostcalls + // Copyright 2024 Fastly, Inc. +// package fastly import ( - "github.com/fastly/compute-sdk-go/internal/abi/prim" + "github.com/fastly/compute-sdk-go/internal/abi/prim" ) // witx: // (module $fastly_compute_runtime -// (@interface func (export "get_vcpu_ms") -// (result $err (expected $vcpu_ms (error $fastly_status))) -// ) +// +// (@interface func (export "get_vcpu_ms") +// (result $err (expected $vcpu_ms (error $fastly_status))) +// ) +// // ) // //go:wasmimport fastly_compute_runtime get_vcpu_ms @@ -29,13 +33,13 @@ func fastlyGetVCPUMs(prim.Pointer[prim.U64]) FastlyStatus // The resulting percentage should be relatively stable across different // platforms, and useful in doing A/B testing. func GetVCPUMilliseconds() (uint64, error) { - var milliseconds prim.U64 + var milliseconds prim.U64 - err := fastlyGetVCPUMs(prim.ToPointer(&milliseconds)).toError() + err := fastlyGetVCPUMs(prim.ToPointer(&milliseconds)).toError() - if err != nil { - return 0, err - } + if err != nil { + return 0, err + } - return uint64(milliseconds), nil + return uint64(milliseconds), nil } From 15b0849c5a62214709ef23184bd195130a2e706b Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 21:09:55 +0000 Subject: [PATCH 16/17] Bump Viceroy version. --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index b232995..a1553b2 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -36,7 +36,7 @@ jobs: - name: Install Viceroy ${{ env.VICEROY_VERSION }} shell: 'bash' env: - VICEROY_VERSION: 0.10.2 + VICEROY_VERSION: 0.11.0 run: | echo "Install Viceroy ${{ env.VICEROY_VERSION }}..." wget --no-verbose https://github.com/fastly/Viceroy/releases/download/v${{ env.VICEROY_VERSION }}/viceroy_v${{ env.VICEROY_VERSION }}_linux-amd64.tar.gz From d203ed14e3a3daf73fc430ea73b1d8fbe6cec053 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Fri, 30 Aug 2024 22:04:35 +0000 Subject: [PATCH 17/17] Reduce the time in a test case --- integration_tests/compute_runtime/main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/compute_runtime/main_test.go b/integration_tests/compute_runtime/main_test.go index e1f8e54..14d454a 100644 --- a/integration_tests/compute_runtime/main_test.go +++ b/integration_tests/compute_runtime/main_test.go @@ -16,14 +16,14 @@ func TestGetVcpuMs(t *testing.T) { t.Errorf("Couldn't get starting vcpu time") } - time.Sleep(2 * time.Second) + time.Sleep(1 * time.Second) end, err := compute.GetVCPUTime() if err != nil { t.Errorf("Couldn't get ending vcpu time") } - if end - start > (500 * time.Millisecond) { + if end - start > (200 * time.Millisecond) { t.Errorf("Sleeping shouldn't count as vcpu time!") }