aboutsummaryrefslogtreecommitdiff
path: root/src/zencompute/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-18 11:27:07 +0100
committerGitHub Enterprise <[email protected]>2026-03-18 11:27:07 +0100
commite64d76ae1b6993582bf161a61049f0771414a779 (patch)
tree083f3df42cc9e2c7ddbee225708b4848eb217d11 /src/zencompute/include
parentCompute batching (#849) (diff)
downloadzen-e64d76ae1b6993582bf161a61049f0771414a779.tar.xz
zen-e64d76ae1b6993582bf161a61049f0771414a779.zip
Simple S3 client (#836)
This functionality is intended to be used to manage datasets for test cases, but may be useful elsewhere in the future. - **Add S3 client with AWS Signature V4 (SigV4) signing** — new `S3Client` in `zenutil/cloud/` supporting `GetObject`, `PutObject`, `DeleteObject`, `HeadObject`, and `ListObjects` operations - **Add EC2 IMDS credential provider** — automatically fetches and refreshes temporary AWS credentials from the EC2 Instance Metadata Service (IMDSv2) for use by the S3 client - **Add SigV4 signing library** — standalone implementation of AWS Signature Version 4 request signing (headers and query-string presigning) - **Add path-style addressing support** — enables compatibility with S3-compatible stores like MinIO (in addition to virtual-hosted style) - **Add S3 integration tests** — includes a `MinioProcess` test helper that spins up a local MinIO server, plus integration tests exercising the S3 client end-to-end - **Add S3-backed `HttpObjectStoreService` tests** — integration tests verifying the zenserver object store works against an S3 backend - **Refactor mock IMDS into `zenutil/cloud/`** — moved and generalized the mock IMDS server from `zencompute` so it can be reused by both compute and S3 credential tests
Diffstat (limited to 'src/zencompute/include')
-rw-r--r--src/zencompute/include/zencompute/cloudmetadata.h12
-rw-r--r--src/zencompute/include/zencompute/mockimds.h100
2 files changed, 4 insertions, 108 deletions
diff --git a/src/zencompute/include/zencompute/cloudmetadata.h b/src/zencompute/include/zencompute/cloudmetadata.h
index a5bc5a34d..3b9642ac3 100644
--- a/src/zencompute/include/zencompute/cloudmetadata.h
+++ b/src/zencompute/include/zencompute/cloudmetadata.h
@@ -2,6 +2,8 @@
#pragma once
+#include <zenutil/cloud/cloudprovider.h>
+
#include <zencore/compactbinarybuilder.h>
#include <zencore/logging.h>
#include <zencore/thread.h>
@@ -13,16 +15,6 @@
namespace zen::compute {
-enum class CloudProvider
-{
- None,
- AWS,
- Azure,
- GCP
-};
-
-std::string_view ToString(CloudProvider Provider);
-
/** Snapshot of detected cloud instance properties. */
struct CloudInstanceInfo
{
diff --git a/src/zencompute/include/zencompute/mockimds.h b/src/zencompute/include/zencompute/mockimds.h
index 521722e63..704306913 100644
--- a/src/zencompute/include/zencompute/mockimds.h
+++ b/src/zencompute/include/zencompute/mockimds.h
@@ -1,102 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
+// Moved to zenutil — this header is kept for backward compatibility.
#pragma once
-#include <zencompute/cloudmetadata.h>
-#include <zenhttp/httpserver.h>
-
-#include <string>
-
-#if ZEN_WITH_TESTS
-
-namespace zen::compute {
-
-/**
- * Mock IMDS (Instance Metadata Service) for testing CloudMetadata.
- *
- * Implements an HttpService that responds to the same URL paths as the real
- * cloud provider metadata endpoints (AWS IMDSv2, Azure IMDS, GCP metadata).
- * Tests configure which provider is "active" and set the desired response
- * values, then pass the mock server's address as the ImdsEndpoint to the
- * CloudMetadata constructor.
- *
- * When a request arrives for a provider that is not the ActiveProvider, the
- * mock returns 404, causing CloudMetadata to write a sentinel file and move
- * on to the next provider — exactly like a failed probe on bare metal.
- *
- * All config fields are public and can be mutated between poll cycles to
- * simulate state changes (e.g. a spot interruption appearing mid-run).
- *
- * Usage:
- * MockImdsService Mock;
- * Mock.ActiveProvider = CloudProvider::AWS;
- * Mock.Aws.InstanceId = "i-test";
- * // ... stand up ASIO server, register Mock, create CloudMetadata with endpoint
- */
-class MockImdsService : public HttpService
-{
-public:
- /** AWS IMDSv2 response configuration. */
- struct AwsConfig
- {
- std::string Token = "mock-aws-token-v2";
- std::string InstanceId = "i-0123456789abcdef0";
- std::string AvailabilityZone = "us-east-1a";
- std::string LifeCycle = "on-demand"; // "spot" or "on-demand"
-
- // Empty string → endpoint returns 404 (instance not in an ASG).
- // Non-empty → returned as the response body. "InService" means healthy;
- // anything else (e.g. "Terminated:Wait") triggers termination detection.
- std::string AutoscalingState;
-
- // Empty string → endpoint returns 404 (no spot interruption).
- // Non-empty → returned as the response body, signalling a spot reclaim.
- std::string SpotAction;
- };
-
- /** Azure IMDS response configuration. */
- struct AzureConfig
- {
- std::string VmId = "vm-12345678-1234-1234-1234-123456789abc";
- std::string Location = "eastus";
- std::string Priority = "Regular"; // "Spot" or "Regular"
-
- // Empty → instance is not in a VM Scale Set (no autoscaling).
- std::string VmScaleSetName;
-
- // Empty → no scheduled events. Set to "Preempt", "Terminate", or
- // "Reboot" to simulate a termination-class event.
- std::string ScheduledEventType;
- std::string ScheduledEventStatus = "Scheduled";
- };
-
- /** GCP metadata response configuration. */
- struct GcpConfig
- {
- std::string InstanceId = "1234567890123456789";
- std::string Zone = "projects/123456/zones/us-central1-a";
- std::string Preemptible = "FALSE"; // "TRUE" or "FALSE"
- std::string MaintenanceEvent = "NONE"; // "NONE" or event description
- };
-
- /** Which provider's endpoints respond successfully.
- * Requests targeting other providers receive 404.
- */
- CloudProvider ActiveProvider = CloudProvider::None;
-
- AwsConfig Aws;
- AzureConfig Azure;
- GcpConfig Gcp;
-
- const char* BaseUri() const override;
- void HandleRequest(HttpServerRequest& Request) override;
-
-private:
- void HandleAwsRequest(HttpServerRequest& Request);
- void HandleAzureRequest(HttpServerRequest& Request);
- void HandleGcpRequest(HttpServerRequest& Request);
-};
-
-} // namespace zen::compute
-
-#endif // ZEN_WITH_TESTS
+#include <zenutil/cloud/mockimds.h>