Skip to content

Commit 5438ded

Browse files
author
Hana Sheto
committed
update in test
1 parent 11e616d commit 5438ded

File tree

4 files changed

+93
-21
lines changed

4 files changed

+93
-21
lines changed

sdk/iotoperations/Azure.ResourceManager.IotOperations/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/iotoperations/Azure.ResourceManager.IotOperations",
5-
"Tag": "net/iotoperations/Azure.ResourceManager.IotOperations_4887017c2b"
5+
"Tag": "net/iotoperations/Azure.ResourceManager.IotOperations_6c69e93b67"
66
}

sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/Tests/AkriConnectorTemplateTests.cs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,42 @@ public async Task TestAkriConnectorTemplates()
6060

6161
private AkriConnectorTemplateResourceData CreateAkriConnectorTemplateResourceData()
6262
{
63-
// Step 1: Create Helm configuration settings
64-
var helmSettings = new AkriConnectorTemplateHelmConfigurationSettings(
65-
releaseName: "my-release",
66-
repositoryName: "my-repo",
67-
version: "1.0.0"
68-
);
63+
// ManagedConfiguration with ImageConfiguration (registry, tag) and bucketized allocation
64+
var imageSettings = new AkriConnectorTemplateRuntimeImageConfigurationSettings("aio-connectors/media-connector")
65+
{
66+
RegistrySettings = new AkriConnectorsContainerRegistry(
67+
new AkriConnectorsContainerRegistrySettings("mcr.microsoft.com")
68+
),
69+
TagDigestSettings = new AkriConnectorsTag("1.2.13"),
70+
};
71+
72+
var managedImageConfig = new AkriConnectorTemplateRuntimeImageConfiguration(imageSettings)
73+
{
74+
Allocation = new AkriConnectorTemplateBucketizedAllocation(5),
75+
};
6976

70-
// Step 2: Add Helm chart values
71-
helmSettings.Values["image"] = "my-image";
72-
helmSettings.Values["replicaCount"] = "2";
77+
var runtimeConfiguration = new AkriConnectorTemplateManagedConfiguration(managedImageConfig);
7378

74-
// Step 3: Create Helm runtime configuration
75-
var helmConfiguration = new AkriConnectorTemplateHelmConfiguration(helmSettings);
79+
// Device inbound endpoint type: Microsoft.Media with default streams config schema ref
80+
var mediaSchemaRefs = new AkriConnectorTemplateDeviceInboundEndpointConfigurationSchemaRefs
81+
{
82+
DefaultStreamsConfigSchemaRef = "aio-sr://${schemaRegistry.properties.namespace}/media-stream-config-schema:1",
83+
};
7684

77-
// Step 4: Define device inbound endpoint types
7885
var inboundEndpoints = new[]
7986
{
80-
new AkriConnectorTemplateDeviceInboundEndpointType("Custom")
87+
new AkriConnectorTemplateDeviceInboundEndpointType("Microsoft.Media")
88+
{
89+
ConfigurationSchemaRefs = mediaSchemaRefs
90+
}
8191
};
8292

83-
// Step 5: Build and return the resource data
93+
// Build and return the resource data, including extended location (CustomLocation)
8494
return new AkriConnectorTemplateResourceData
8595
{
96+
ExtendedLocation = new IotOperationsExtendedLocation(ExtendedLocation, IotOperationsExtendedLocationType.CustomLocation),
8697
Properties = new AkriConnectorTemplateProperties(
87-
runtimeConfiguration: helmConfiguration,
98+
runtimeConfiguration: runtimeConfiguration,
8899
deviceInboundEndpointTypes: inboundEndpoints
89100
)
90101
};

sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/Tests/AkriConnectorTests.cs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// Licensed under the MIT License.
33

44
using System.Threading.Tasks;
5+
using Azure; // for RequestFailedException, WaitUntil, ArmOperation
56
using Azure.Core.TestFramework;
6-
7+
using Azure.ResourceManager.IotOperations.Models; // for AkriConnector* models
78
using NUnit.Framework;
89

910
namespace Azure.ResourceManager.IotOperations.Tests
@@ -14,10 +15,55 @@ public AkriConnectorTests(bool isAsync)
1415
: base(isAsync) { }
1516

1617
[SetUp]
17-
public async Task SetUp()
18+
public async Task ClearAndInitialize()
19+
{
20+
if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
21+
{
22+
await InitializeClients();
23+
}
24+
}
25+
26+
[RecordedTest]
27+
public async Task TestAkriConnectorCrud()
1828
{
19-
// Ensure AkriConnectorTemplateName is set
20-
AkriConnectorTemplateName = "default";
29+
// Ensure AkriConnectorTemplateName is set and exists
30+
AkriConnectorTemplateName = "sdk-test-akriconnector-template";
31+
var templateCollection = await GetAkriConnectorTemplateResourceCollectionAsync(ResourceGroup);
32+
if (!await templateCollection.ExistsAsync(AkriConnectorTemplateName))
33+
{
34+
// Create a minimal template compatible with ManagedConfiguration used elsewhere
35+
var imageSettings = new AkriConnectorTemplateRuntimeImageConfigurationSettings("aio-connectors/media-connector")
36+
{
37+
RegistrySettings = new AkriConnectorsContainerRegistry(
38+
new AkriConnectorsContainerRegistrySettings("mcr.microsoft.com")
39+
),
40+
TagDigestSettings = new AkriConnectorsTag("1.2.13"),
41+
};
42+
var managedImageConfig = new AkriConnectorTemplateRuntimeImageConfiguration(imageSettings)
43+
{
44+
Allocation = new AkriConnectorTemplateBucketizedAllocation(5),
45+
};
46+
var runtimeConfiguration = new AkriConnectorTemplateManagedConfiguration(managedImageConfig);
47+
var mediaSchemaRefs = new AkriConnectorTemplateDeviceInboundEndpointConfigurationSchemaRefs
48+
{
49+
DefaultStreamsConfigSchemaRef = "aio-sr://${schemaRegistry.properties.namespace}/media-stream-config-schema:1",
50+
};
51+
var inboundEndpoints = new[]
52+
{
53+
new AkriConnectorTemplateDeviceInboundEndpointType("Microsoft.Media")
54+
{
55+
ConfigurationSchemaRefs = mediaSchemaRefs
56+
}
57+
};
58+
var templateData = new AkriConnectorTemplateResourceData
59+
{
60+
ExtendedLocation = new IotOperationsExtendedLocation(ExtendedLocation, IotOperationsExtendedLocationType.CustomLocation),
61+
Properties = new AkriConnectorTemplateProperties(runtimeConfiguration, inboundEndpoints)
62+
};
63+
64+
await templateCollection.CreateOrUpdateAsync(WaitUntil.Completed, AkriConnectorTemplateName, templateData);
65+
}
66+
2167
var connectorCollection = await GetAkriConnectorResourceCollectionAsync();
2268

2369
// Get existing AkriConnectorResource (if any)

sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/Tests/DataflowGraphTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System.Threading.Tasks;
5+
using Azure; // RequestFailedException
56
using Azure.Core.TestFramework;
67
using NUnit.Framework;
78
using Azure.ResourceManager.IotOperations.Models;
@@ -28,11 +29,25 @@ public async Task TestDataflowGraphs()
2829
var dataflowProfileResource = await dataflowProfileCollection.GetAsync(DataflowProfilesName);
2930
var graphCollection = dataflowProfileResource.Value.GetDataflowGraphResources();
3031

32+
// Use a unique name to avoid conflicts with in-progress operations
33+
var graphName = Recording.GenerateAssetName("sdk-test-dataflowgraph-");
34+
35+
// Best-effort cleanup if an earlier run left a resource
36+
try
37+
{
38+
var existing = await graphCollection.GetAsync(graphName);
39+
await existing.Value.DeleteAsync(WaitUntil.Completed);
40+
}
41+
catch (RequestFailedException)
42+
{
43+
// ignore if not found
44+
}
45+
3146
// Create DataflowGraph
3247
var graphData = CreateDataflowGraphResourceData();
3348
var createOperation = await graphCollection.CreateOrUpdateAsync(
3449
WaitUntil.Completed,
35-
"sdk-test-dataflowgraph",
50+
graphName,
3651
graphData
3752
);
3853
var createdGraph = createOperation.Value;

0 commit comments

Comments
 (0)