From e92a8bb78ca7b47a7f4a4e1f82bcd6b88fc02e29 Mon Sep 17 00:00:00 2001 From: Victor XField Date: Wed, 27 Jan 2021 18:26:15 -0800 Subject: [PATCH 1/2] Improve Az Login logic for recording auth --- .../tests/Tests/TestBase.cs | 72 ++++++++++++++----- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/TestBase.cs b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/TestBase.cs index aee855e640e6c..535b069e955cd 100644 --- a/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/TestBase.cs +++ b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/TestBase.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Runtime.InteropServices; namespace Microsoft.Azure.Management.Quantum.Tests { @@ -23,7 +24,7 @@ internal virtual void TestInitialize([System.Runtime.CompilerServices.CallerMemb { Context = QuantumMockContext.Start(this.GetType(), methodName); - UseAccessTokenIfNeeded(); + UseAzLoginCredentialsIfNeeded(); CommonData = new CommonTestFixture(); QuantumClient = Context.GetServiceClient(); @@ -45,29 +46,64 @@ internal virtual void TestInitialize([System.Runtime.CompilerServices.CallerMemb } } - private static void UseAccessTokenIfNeeded() + private static void UseAzLoginCredentialsIfNeeded() { - var testConnectionString = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION"); - if (!string.IsNullOrEmpty(testConnectionString) && !testConnectionString.Contains("ServicePrincipal=") && IsRecordMode) + if (IsRecordMode) { - var azProcess = new Process() + var testConnectionString = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION"); + AzLoginAccessTokenInfo accessTokenInfo = null; + if (string.IsNullOrEmpty(testConnectionString)) { - StartInfo = new ProcessStartInfo("cmd.exe", "/c az account get-access-token") - { - CreateNoWindow = true, - RedirectStandardError = true, - RedirectStandardInput = true, - RedirectStandardOutput = true - } - }; - azProcess.Start(); - azProcess.WaitForExit(); - var output = azProcess.StandardOutput.ReadToEnd(); - var accessToken = JObject.Parse(output)["accessToken"].Value(); - Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", $"{testConnectionString}RawToken={accessToken};"); + accessTokenInfo = GetAzLoginAccessTokenInfo(); + if (accessTokenInfo == null) return; + testConnectionString = $"SubscriptionId={accessTokenInfo.SubscriptionId};AADTenant={accessTokenInfo.TenantId};Environment=Prod;HttpRecorderMode=Record;"; + Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", testConnectionString); + } + if (!testConnectionString.Contains("ServicePrincipal=")) + accessTokenInfo = accessTokenInfo ?? GetAzLoginAccessTokenInfo(); { + if (accessTokenInfo == null) return; + Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", $"{testConnectionString};RawToken={accessTokenInfo.AccessToken};"); + } } } + private class AzLoginAccessTokenInfo + { + [JsonProperty("subscription")] + public string SubscriptionId { get; set; } + + [JsonProperty("tenant")] + public string TenantId { get; set; } + + [JsonProperty("accessToken")] + public string AccessToken { get; set; } + } + + private static AzLoginAccessTokenInfo GetAzLoginAccessTokenInfo() + { + bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + if (!isWindows) + { + return null; + } + + var azProcess = new Process() + { + StartInfo = new ProcessStartInfo("cmd.exe", "/c az account get-access-token") + { + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardInput = true, + RedirectStandardOutput = true + } + }; + azProcess.Start(); + azProcess.WaitForExit(); + var azProcessOutput = azProcess.StandardOutput.ReadToEnd(); + var accessTokenInfo = JsonConvert.DeserializeObject(azProcessOutput); + return accessTokenInfo; + } + protected virtual void CreateResources() { //create resource group From 69fcd5b4d304068fa88ae3581b7f04c5b5c75df4 Mon Sep 17 00:00:00 2001 From: Victor XField Date: Wed, 27 Jan 2021 18:27:12 -0800 Subject: [PATCH 2/2] Adding remaining test cases --- .../TestListOfferings.json | 78 +++++++++++++++++++ .../OperationsTests/TestListOperations.json | 78 +++++++++++++++++++ .../tests/Tests/OfferingOperationTests.cs | 28 +++++++ .../tests/Tests/OperationsTests.cs | 26 +++++++ 4 files changed, 210 insertions(+) create mode 100644 sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OfferingOperationTests/TestListOfferings.json create mode 100644 sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OperationsTests/TestListOperations.json create mode 100644 sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OfferingOperationTests.cs create mode 100644 sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OperationsTests.cs diff --git a/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OfferingOperationTests/TestListOfferings.json b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OfferingOperationTests/TestListOfferings.json new file mode 100644 index 0000000000000..4093cbb851d95 --- /dev/null +++ b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OfferingOperationTests/TestListOfferings.json @@ -0,0 +1,78 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/5380fe2c-2752-458a-833f-a61d7ababc9a/providers/Microsoft.Quantum/locations/westus/offerings?api-version=2019-11-04-preview", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "ca007c26-6301-40a6-8a35-53f194b97694" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.29518.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Quantum.QuantumManagementClient/1.0.0.1" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "f1de4c44-b46b-4241-aae7-9c7851ec8a4b" + ], + "x-ms-correlation-request-id": [ + "65cf1945-a79f-4d26-9e2d-47b6fceb09af" + ], + "Server": [ + "Kestrel" + ], + "x-ms-routing-request-id": [ + "WESTUS:20210127T224234Z:65cf1945-a79f-4d26-9e2d-47b6fceb09af" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Wed, 27 Jan 2021 22:42:33 GMT" + ], + "Content-Length": [ + "16603" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"1qbit\",\r\n \"name\": \"1Qloud Optimization Platform\",\r\n \"properties\": {\r\n \"description\": \"1QBit 1Qloud Optimization Platform with Quantum Inspired Solutions\",\r\n \"providerType\": \"qio\",\r\n \"company\": \"1QBit\",\r\n \"managedApplication\": {\r\n \"publisherId\": \"1qbinformationtechnologies1580939206424\",\r\n \"offerId\": \"1qbit-1qloud-optimization\"\r\n },\r\n \"targets\": [\r\n {\r\n \"id\": \"1qbit.tabu\",\r\n \"name\": \"1QBit Quadratic Tabu Solver\",\r\n \"description\": \"An iterative heuristic algorithm that uses local search techniques to solve a problem\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"1qbit.pathrelinking\",\r\n \"name\": \"1QBit Quadratic Path-Relinking Solver\",\r\n \"description\": \"The path-relinking algorithm is a heuristic algorithm that uses the tabu search as a subroutine to solve a QUBO problem\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"1qbit.pticm\",\r\n \"name\": \"1QBit Quadratic Parallel Tempering Isoenergetic Cluster Moves Solver\",\r\n \"description\": \"The parallel tempering with isoenergetic cluster moves (PTICM) solver is a Monte Carlo approach to solving QUBO problems\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n }\r\n ],\r\n \"skus\": [\r\n {\r\n \"id\": \"1qbit-internal-free-plan\",\r\n \"name\": \"1QBit no charge plan\",\r\n \"description\": \"1QBit plan with no charge for specific customer arrangements\",\r\n \"targets\": [\r\n \"1qbit.tabu\",\r\n \"1qbit.pathrelinking\",\r\n \"1qbit.pticm\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"Tabu Search Solver
Path-Relinking Solver
PTICM Solver\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"50 hours / month\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"Free in Private Preview\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"1qbit-fixed-monthly-202012\",\r\n \"name\": \"Fixed Monthly Plan\",\r\n \"description\": \"This plan provides access to all 1QBit quantum inspired optimization solvers with a flat monthly fee\",\r\n \"targets\": [\r\n \"1qbit.tabu\",\r\n \"1qbit.pathrelinking\",\r\n \"1qbit.pticm\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"Tabu Search Solver
Path-Relinking Solver
PTICM Solver\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"N/A\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"$7500 USD / month\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"pricingDimensions\": [\r\n {\r\n \"id\": \"features\",\r\n \"name\": \"Features\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"name\": \"Quota\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"name\": \"Pricing\"\r\n }\r\n ]\r\n }\r\n },\r\n {\r\n \"id\": \"honeywell\",\r\n \"name\": \"Honeywell Quantum Solutions\",\r\n \"properties\": {\r\n \"description\": \"Access to Honeywell Quantum Solutions' trapped-ion systems\",\r\n \"providerType\": \"qe\",\r\n \"company\": \"Honeywell\",\r\n \"managedApplication\": {\r\n \"publisherId\": \"honeywell-quantum\",\r\n \"offerId\": \"honeywell-quantum-aq\"\r\n },\r\n \"targets\": [\r\n {\r\n \"id\": \"honeywell.hqs-lt-1.0\",\r\n \"name\": \"Honeywell System Model H0\",\r\n \"description\": \"Honeywell System Model H0\",\r\n \"acceptedDataFormats\": [\r\n \"honeywell.openqasm.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\",\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"honeywell.hqs-lt-1.0-apival\",\r\n \"name\": \"H0 API Validator\",\r\n \"description\": \"Honeywell System Model H0 API Validator\",\r\n \"acceptedDataFormats\": [\r\n \"honeywell.openqasm.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\",\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"honeywell.hqs-lt-s1\",\r\n \"name\": \"Honeywell System Model: H1\",\r\n \"description\": \"Honeywell System Model H1\",\r\n \"acceptedDataFormats\": [\r\n \"honeywell.openqasm.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\",\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"honeywell.hqs-lt-s1-apival\",\r\n \"name\": \"H1 API Validator\",\r\n \"description\": \"Honeywell System Model H1 API Validator\",\r\n \"acceptedDataFormats\": [\r\n \"honeywell.openqasm.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\",\r\n \"identity\"\r\n ]\r\n }\r\n ],\r\n \"skus\": [\r\n {\r\n \"id\": \"usage2\",\r\n \"name\": \"Queued Access\",\r\n \"description\": \"Computational consumption plan with queued access. Jobs are queued in a fair and equitable manner\",\r\n \"targets\": [\r\n \"honeywell.hqs-lt-1.0\",\r\n \"honeywell.hqs-lt-1.0-apival\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"System Model H0 API Validator
System Model H0 (6 qubits)\"\r\n },\r\n {\r\n \"id\": \"pricing\",\r\n \"value\": \"$ 6.40 USD / HQC
$ 5,000 / Reserved Hour
See preview documentation for details\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"standard\",\r\n \"version\": \"1.0.0\",\r\n \"name\": \"Standard\",\r\n \"description\": \"Subscription plan with 8 hours of reserved access and unrestricted, queued access.\",\r\n \"targets\": [\r\n \"honeywell.hqs-lt-s1\",\r\n \"honeywell.hqs-lt-s1-apival\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"System Model H1 API Validator
System Model H1 (10 qubits)\"\r\n },\r\n {\r\n \"id\": \"pricing\",\r\n \"value\": \"$ 100,000 USD / Month\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"premium\",\r\n \"version\": \"1.0.0\",\r\n \"name\": \"Premium\",\r\n \"description\": \"Subscription plan with 16 hours of reserved access and unrestricted, queued access.\",\r\n \"targets\": [\r\n \"honeywell.hqs-lt-s1\",\r\n \"honeywell.hqs-lt-s1-apival\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"System Model H1 API Validator
System Model H1 (10 qubits)\"\r\n },\r\n {\r\n \"id\": \"pricing\",\r\n \"value\": \"$ 150,000 USD / Month\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"test1\",\r\n \"version\": \"1.0.0\",\r\n \"name\": \"Partner Access\",\r\n \"description\": \"Charge-free access to Honeywell System Model H0 for initial Azure integration verification\",\r\n \"targets\": [\r\n \"honeywell.hqs-lt-1.0\",\r\n \"honeywell.hqs-lt-1.0-apival\",\r\n \"honeywell.hqs-lt-s1\",\r\n \"honeywell.hqs-lt-s1-apival\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"System Model H0 API Validator
System Model H0 (6 qubits)\"\r\n },\r\n {\r\n \"id\": \"pricing\",\r\n \"value\": \"Free for validation\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"pricingDimensions\": [\r\n {\r\n \"id\": \"features\",\r\n \"name\": \"Features\"\r\n },\r\n {\r\n \"id\": \"pricing\",\r\n \"name\": \"Pricing\"\r\n }\r\n ]\r\n }\r\n },\r\n {\r\n \"id\": \"ionq\",\r\n \"name\": \"IonQ\",\r\n \"properties\": {\r\n \"description\": \"IonQ’s trapped ion quantum computers perform calculations by manipulating charged atoms of Ytterbium held in a vacuum with lasers.\",\r\n \"providerType\": \"qe\",\r\n \"company\": \"IonQ\",\r\n \"managedApplication\": {\r\n \"publisherId\": \"ionqinc1582730893633\",\r\n \"offerId\": \"ionq-aq\"\r\n },\r\n \"targets\": [\r\n {\r\n \"id\": \"ionq.simulator\",\r\n \"name\": \"Trapped Ion Quantum Computer Simulator\",\r\n \"description\": \"GPU-accelerated idealized simulator supporting up to 29 qubits, using the same gates IonQ provides on its quantum computers. No errors are modeled at present.\",\r\n \"acceptedDataFormats\": [\r\n \"ionq.circuit.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"ionq.qpu\",\r\n \"name\": \"Trapped Ion Quantum Computer\",\r\n \"description\": \"IonQ's quantum computer is dynamically reconfigurable in software to use up to 11 qubits. All qubits are fully connected, meaning you can run a two-qubit gate between any pair.\",\r\n \"acceptedDataFormats\": [\r\n \"ionq.circuit.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n }\r\n ],\r\n \"skus\": [\r\n {\r\n \"id\": \"pay-as-you-go\",\r\n \"name\": \"Pay As You Go\",\r\n \"description\": \"A la carte access based on resource requirements and usage.\",\r\n \"targets\": [\r\n \"ionq.qpu\",\r\n \"ionq.simulator\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"IonQ Simulator
Trapped Ion QC (11 qubits)\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"N/A\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"$ 3,000.00 USD / hour (est)
See preview documentation for details\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"limited-preview\",\r\n \"version\": \"0.0.3\",\r\n \"name\": \"Public Preview\",\r\n \"description\": \"A la carte access based on resource requirements and usage.\",\r\n \"targets\": [\r\n \"ionq.qpu\",\r\n \"ionq.simulator\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"IonQ Simulator
Trapped Ion QC (11 qubits)\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"N/A\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"$ 3,000.00 USD / hour (est)
See preview documentation for details\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"public-preview\",\r\n \"version\": \"0.0.3\",\r\n \"name\": \"[Deprecated]\",\r\n \"description\": \"[Deprecated] A la carte access based on resource requirements and usage.\",\r\n \"targets\": [\r\n \"ionq.qpu\",\r\n \"ionq.simulator\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"IonQ Simulator
Trapped Ion QC (11 qubits)\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"1st hour free / month\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"$ 3,000.00 USD / hour (est)
See preview documentation for details\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"private-preview\",\r\n \"version\": \"0.0.3\",\r\n \"name\": \"Private Preview\",\r\n \"description\": \"Use up to approximately 1 hour per month of quantum computer time for free during private preview!\",\r\n \"targets\": [\r\n \"ionq.qpu\",\r\n \"ionq.simulator\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"IonQ Simulator
Trapped Ion QC (11 qubits)\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"1st hour free / month\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"$ 2,400.00 USD / hour (est)
See preview documentation for details\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"ionq-standard\",\r\n \"version\": \"0.0.3\",\r\n \"name\": \"IonQ Standard\",\r\n \"description\": \"You're testing, so it's free! As in beer.\",\r\n \"targets\": [\r\n \"ionq.qpu\",\r\n \"ionq.simulator\"\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"features\",\r\n \"value\": \"IonQ Simulator
Trapped Ion QC (11 qubits)\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"N/A\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"Free\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"pricingDimensions\": [\r\n {\r\n \"id\": \"features\",\r\n \"name\": \"Features\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"name\": \"Quota\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"name\": \"Pricing\"\r\n }\r\n ]\r\n }\r\n },\r\n {\r\n \"id\": \"Microsoft\",\r\n \"name\": \"Microsoft QIO\",\r\n \"properties\": {\r\n \"description\": \"Ground-breaking optimization algorithms inspired by decades of quantum research.\",\r\n \"providerType\": \"qio\",\r\n \"company\": \"Microsoft\",\r\n \"managedApplication\": {\r\n \"publisherId\": \"N/A\",\r\n \"offerId\": \"N/A\"\r\n },\r\n \"targets\": [\r\n {\r\n \"id\": \"microsoft.paralleltempering.cpu\",\r\n \"name\": \"microsoft.paralleltempering.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.simulatedannealing-parameterfree.cpu\",\r\n \"name\": \"microsoft.simulatedannealing-parameterfree.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.paralleltempering-parameterfree.cpu\",\r\n \"name\": \"microsoft.paralleltempering-parameterfree.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.simulatedannealing.cpu\",\r\n \"name\": \"microsoft.simulatedannealing.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.tabu.cpu\",\r\n \"name\": \"microsoft.tabu.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.tabu-parameterfree.cpu\",\r\n \"name\": \"microsoft.tabu-parameterfree.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.simulatedannealing-parameterfree.fpga\",\r\n \"name\": \"microsoft.simulatedannealing-parameterfree.fpga\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.simulatedannealing.fpga\",\r\n \"name\": \"microsoft.simulatedannealing.fpga\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n },\r\n {\r\n \"id\": \"microsoft.qmc.cpu\",\r\n \"name\": \"microsoft.qmc.cpu\",\r\n \"acceptedDataFormats\": [\r\n \"microsoft.qio.v1\",\r\n \"microsoft.qio.v2\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"gzip\"\r\n ]\r\n }\r\n ],\r\n \"skus\": [\r\n {\r\n \"id\": \"Basic\",\r\n \"name\": \"Private Preview\",\r\n \"description\": \"Free Private Preview access through February 15 2020\",\r\n \"targets\": [\r\n \"microsoft.simulatedannealing.fpga\",\r\n \"microsoft.simulatedannealing-parameterfree.fpga\",\r\n \"microsoft.paralleltempering-parameterfree.cpu\",\r\n \"microsoft.paralleltempering.cpu\",\r\n \"microsoft.simulatedannealing-parameterfree.cpu\",\r\n \"microsoft.simulatedannealing.cpu\",\r\n \"microsoft.tabu-parameterfree.cpu\",\r\n \"microsoft.tabu.cpu\",\r\n \"microsoft.qmc.cpu\"\r\n ],\r\n \"quotaDimensions\": [\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Workspace\"\r\n },\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Subscription\"\r\n },\r\n {\r\n \"id\": \"concurrent_cpu_jobs\",\r\n \"scope\": \"Workspace\"\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Workspace\"\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Subscription\"\r\n },\r\n {\r\n \"id\": \"concurrent_fpga_jobs\",\r\n \"scope\": \"Workspace\"\r\n }\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"targets\",\r\n \"value\": \"Simulated annealing
Simulated annealing (Parameter-free)
Parallel tempering
Parallel tempering (Parameter-free)
Quantum Monte Carlo

FPGA simulated annealing\"\r\n },\r\n {\r\n \"id\": \"perf\",\r\n \"value\": \"CPU based: Up to 5 concurrent jobs
FPGA based: Up to 1 concurrent jobs\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"CPU based: 5 hours / month
FPGA based: 1 hour / month\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"$ 0\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"DZH3178M639F\",\r\n \"version\": \"1.0\",\r\n \"name\": \"Learn & Develop\",\r\n \"description\": \"Learn and develop with Optimization solutions.\",\r\n \"targets\": [\r\n \"microsoft.simulatedannealing.fpga\",\r\n \"microsoft.simulatedannealing-parameterfree.fpga\",\r\n \"microsoft.paralleltempering-parameterfree.cpu\",\r\n \"microsoft.paralleltempering.cpu\",\r\n \"microsoft.simulatedannealing-parameterfree.cpu\",\r\n \"microsoft.simulatedannealing.cpu\",\r\n \"microsoft.tabu-parameterfree.cpu\",\r\n \"microsoft.tabu.cpu\",\r\n \"microsoft.qmc.cpu\"\r\n ],\r\n \"quotaDimensions\": [\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 20\r\n },\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Subscription\"\r\n },\r\n {\r\n \"id\": \"concurrent_cpu_jobs\",\r\n \"scope\": \"Workspace\"\r\n },\r\n {\r\n \"id\": \"concurrent_fpga_jobs\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 2\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Workspace\"\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Subscription\"\r\n }\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"targets\",\r\n \"value\": \"Simulated annealing
Simulated annealing (Parameter-free)
Parallel tempering
Parallel tempering (Parameter-free)
Quantum Monte Carlo

FPGA simulated annealing\"\r\n },\r\n {\r\n \"id\": \"perf\",\r\n \"value\": \"CPU based: Up to 5 concurrent jobs
FPGA based: Up to 2 concurrent jobs\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"CPU based: 20 hours / month
FPGA based: 1 hour / month\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"Pay as you go
1 free hour included

See pricing sheet\"\r\n }\r\n ]\r\n },\r\n {\r\n \"id\": \"DZH318RV7MW4\",\r\n \"version\": \"1.0\",\r\n \"name\": \"Scale\",\r\n \"description\": \"Deploy world-class Optimization solutions.\",\r\n \"targets\": [\r\n \"microsoft.simulatedannealing.fpga\",\r\n \"microsoft.simulatedannealing-parameterfree.fpga\",\r\n \"microsoft.paralleltempering-parameterfree.cpu\",\r\n \"microsoft.paralleltempering.cpu\",\r\n \"microsoft.simulatedannealing-parameterfree.cpu\",\r\n \"microsoft.simulatedannealing.cpu\",\r\n \"microsoft.tabu-parameterfree.cpu\",\r\n \"microsoft.tabu.cpu\",\r\n \"microsoft.qmc.cpu\"\r\n ],\r\n \"quotaDimensions\": [\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 1000\r\n },\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Subscription\"\r\n },\r\n {\r\n \"id\": \"concurrent_cpu_jobs\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 100\r\n },\r\n {\r\n \"id\": \"concurrent_fpga_jobs\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 10\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 1000\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Subscription\"\r\n }\r\n ],\r\n \"pricingDetails\": [\r\n {\r\n \"id\": \"targets\",\r\n \"value\": \"Simulated annealing
Simulated annealing (Parameter-free)
Parallel tempering
Parallel tempering (Parameter-free)
Quantum Monte Carlo

FPGA simulated annealing\"\r\n },\r\n {\r\n \"id\": \"perf\",\r\n \"value\": \"CPU based: Up to 100 concurrent jobs
FPGA based: Up to 10 concurrent jobs\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"value\": \"Up to 50,000 hours / month\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"value\": \"Pay as you go
1 free hour included

See pricing sheet\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"quotaDimensions\": [\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 5,\r\n \"period\": \"Monthly\",\r\n \"name\": \"CPU Solver Hours [Workspace]\",\r\n \"description\": \"The amount of CPU solver time you may use per month within this workspace\",\r\n \"unit\": \"hour\",\r\n \"unitPlural\": \"hours\"\r\n },\r\n {\r\n \"id\": \"combined_job_hours\",\r\n \"scope\": \"Subscription\",\r\n \"quota\": 1000,\r\n \"period\": \"Monthly\",\r\n \"name\": \"CPU Solver Hours [Subscription]\",\r\n \"description\": \"The amount of CPU solver time you may use per month shared by all workspaces within the subscription\",\r\n \"unit\": \"hour\",\r\n \"unitPlural\": \"hours\"\r\n },\r\n {\r\n \"id\": \"concurrent_cpu_jobs\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 5\r\n },\r\n {\r\n \"id\": \"concurrent_fpga_jobs\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 1\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 1,\r\n \"period\": \"Monthly\",\r\n \"name\": \"FPGA Solver Hours [Workspace]\",\r\n \"description\": \"The amount of FPGA solver time you may use per month within this workspace\",\r\n \"unit\": \"hour\",\r\n \"unitPlural\": \"hours\"\r\n },\r\n {\r\n \"id\": \"fpga_job_hours\",\r\n \"scope\": \"Subscription\",\r\n \"quota\": 1000,\r\n \"period\": \"Monthly\",\r\n \"name\": \"FPGA Solver Hours [Subscription]\",\r\n \"description\": \"The amount of FPGA solver time you may use per month shared by all workspaces within the subscription\",\r\n \"unit\": \"hour\",\r\n \"unitPlural\": \"hours\"\r\n }\r\n ],\r\n \"pricingDimensions\": [\r\n {\r\n \"id\": \"targets\",\r\n \"name\": \"Targets available\"\r\n },\r\n {\r\n \"id\": \"perf\",\r\n \"name\": \"Performance\"\r\n },\r\n {\r\n \"id\": \"quota\",\r\n \"name\": \"Quota\"\r\n },\r\n {\r\n \"id\": \"price\",\r\n \"name\": \"Price per month\"\r\n }\r\n ]\r\n }\r\n },\r\n {\r\n \"id\": \"qci\",\r\n \"name\": \"Quantum Circuits, Inc.\",\r\n \"properties\": {\r\n \"description\": \"Superconducting circuits QC\",\r\n \"providerType\": \"qe\",\r\n \"company\": \"Quantum Circuits, Inc.\",\r\n \"managedApplication\": {\r\n \"publisherId\": \"quantumcircuitsinc1598045891596\",\r\n \"offerId\": \"quantumcircuitsinc-aq-test-preview\"\r\n },\r\n \"targets\": [\r\n {\r\n \"id\": \"qci.machine1\",\r\n \"name\": \"Machine 1\",\r\n \"description\": \"Machine 1 Description\",\r\n \"acceptedDataFormats\": [\r\n \"qci.qcdl.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n },\r\n {\r\n \"id\": \"qci.simulator\",\r\n \"name\": \"Simulator\",\r\n \"description\": \"Simulator Description\",\r\n \"acceptedDataFormats\": [\r\n \"qci.qcdl.v1\"\r\n ],\r\n \"acceptedContentEncodings\": [\r\n \"identity\"\r\n ]\r\n }\r\n ],\r\n \"skus\": [\r\n {\r\n \"id\": \"test\",\r\n \"name\": \"test\",\r\n \"description\": \"test sku\",\r\n \"targets\": [\r\n \"qci.simulator\",\r\n \"qci.machine1\"\r\n ],\r\n \"quotaDimensions\": [\r\n {\r\n \"id\": \"jobcount\",\r\n \"scope\": \"Workspace\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"quotaDimensions\": [\r\n {\r\n \"id\": \"jobcount\",\r\n \"scope\": \"Workspace\",\r\n \"quota\": 1000,\r\n \"period\": \"Monthly\",\r\n \"name\": \"Job Count\",\r\n \"description\": \"Number of jobs you can run in a month.\",\r\n \"unit\": \"job\",\r\n \"unitPlural\": \"jobs\"\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + ".ctor": [ + "sdktestrg-2698", + "sdktestst2149" + ], + "TestInitialize": [ + "5380fe2c-2752-458a-833f-a61d7ababc9a" + ] + }, + "Variables": { + "SubscriptionId": "5380fe2c-2752-458a-833f-a61d7ababc9a" + } +} diff --git a/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OperationsTests/TestListOperations.json b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OperationsTests/TestListOperations.json new file mode 100644 index 0000000000000..c989f2b6b93c8 --- /dev/null +++ b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/SessionRecords/OperationsTests/TestListOperations.json @@ -0,0 +1,78 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.Quantum/operations?api-version=2019-11-04-preview", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "f2b27ab4-c3b2-4dfa-a71a-0ad944a35923" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.29518.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19042.", + "Microsoft.Azure.Management.Quantum.QuantumManagementClient/1.0.0.1" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "ae41b3cb-9699-4b75-bf73-a9aaa6ab2c51" + ], + "x-ms-correlation-request-id": [ + "7b220dc0-0a2b-40e3-8910-92350163b936" + ], + "Server": [ + "Kestrel" + ], + "x-ms-routing-request-id": [ + "WESTUS:20210127T224541Z:7b220dc0-0a2b-40e3-8910-92350163b936" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Wed, 27 Jan 2021 22:45:40 GMT" + ], + "Content-Length": [ + "886" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"Microsoft.Quantum/Workspaces/Read\",\r\n \"isDataAction\": false,\r\n \"display\": {\r\n \"provider\": \"Microsoft.Quantum\",\r\n \"resource\": \"Workspaces\",\r\n \"operation\": \"Gets/List workspace resources\",\r\n \"description\": \"Read Workspace\"\r\n }\r\n },\r\n {\r\n \"name\": \"Microsoft.Quantum/Workspaces/Write\",\r\n \"isDataAction\": false,\r\n \"display\": {\r\n \"provider\": \"Microsoft.Quantum\",\r\n \"resource\": \"Workspaces\",\r\n \"operation\": \"Create/update workspace resources\",\r\n \"description\": \"Writes Workspace\"\r\n }\r\n },\r\n {\r\n \"name\": \"Microsoft.Quantum/Workspaces/Delete\",\r\n \"isDataAction\": false,\r\n \"display\": {\r\n \"provider\": \"Microsoft.Quantum\",\r\n \"resource\": \"Workspaces\",\r\n \"operation\": \"Deletes workspace resource\",\r\n \"description\": \"Deletes Workspace\"\r\n }\r\n },\r\n {\r\n \"name\": \"Microsoft.Quantum/Locations/Offerings/Read\",\r\n \"isDataAction\": false,\r\n \"display\": {\r\n \"provider\": \"Microsoft.Quantum\",\r\n \"resource\": \"Workspaces\",\r\n \"operation\": \"Read quantum workspace's available providers\",\r\n \"description\": \"Read providers supported\"\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + ".ctor": [ + "sdktestrg-559", + "sdktestst3589" + ], + "TestInitialize": [ + "396c0337-42f3-410e-b071-1058e0ef3a62" + ] + }, + "Variables": { + "SubscriptionId": "396c0337-42f3-410e-b071-1058e0ef3a62" + } +} diff --git a/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OfferingOperationTests.cs b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OfferingOperationTests.cs new file mode 100644 index 0000000000000..1416e07b04ae9 --- /dev/null +++ b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OfferingOperationTests.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using System.Collections.Generic; +using Xunit; +using System.Threading; +using System.Linq; + +namespace Microsoft.Azure.Management.Quantum.Tests +{ + public class OfferingOperationTests : QuantumManagementTestBase + { + [Fact] + public void TestListOfferings() + { + TestInitialize(); + + var firstPage = QuantumClient.Offerings.List(CommonData.Location); + var offerings = QuantumManagementTestUtilities.ListResources(firstPage, QuantumClient.Offerings.ListNext); + Assert.True(offerings.Count >= 1); + var microsoftQIO = offerings.FirstOrDefault((offering) => "Microsoft".Equals(offering.Id)); + Assert.NotNull(microsoftQIO); + var microsoftQIOBasicSKU = microsoftQIO.Properties.Skus.FirstOrDefault((sku) => "Basic".Equals(sku.Id)); + Assert.NotNull(microsoftQIOBasicSKU); + } + } +} \ No newline at end of file diff --git a/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OperationsTests.cs b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OperationsTests.cs new file mode 100644 index 0000000000000..da98e11a2372a --- /dev/null +++ b/sdk/quantum/Microsoft.Azure.Management.Quantum/tests/Tests/OperationsTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using System.Collections.Generic; +using Xunit; +using System.Threading; +using System.Linq; + +namespace Microsoft.Azure.Management.Quantum.Tests +{ + public class OperationsTests : QuantumManagementTestBase + { + [Fact] + public void TestListOperations() + { + TestInitialize(); + + var firstPage = QuantumClient.Operations.List(); + var operations = QuantumManagementTestUtilities.ListResources(firstPage, QuantumClient.Operations.ListNext); + Assert.True(operations.Count >= 1); + var workspaceRead = operations.FirstOrDefault((operation) => "Microsoft.Quantum/Workspaces/Read".Equals(operation.Name)); + Assert.NotNull(workspaceRead); + } + } +} \ No newline at end of file