Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion e2etest/GuestProxyAgentTest/GuestProxyAgentTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PackageReference Include="Azure.ResourceManager.Resources" Version="1.9" />
<PackageReference Include="Azure.ResourceManager.Storage" Version="1.1.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager.Fluent" Version="1.38.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="YamlDotNet" Version="15.1.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
Expand Down
57 changes: 57 additions & 0 deletions e2etest/GuestProxyAgentTest/Utilities/ResourceNamer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT
namespace GuestProxyAgentTest.Utilities
{
public class ResourceNamer
{
private readonly string randName;

private static string[] formats = new string[1] { "M/d/yyyy h:mm:ss tt" };

private static Random random = new Random();

public ResourceNamer(string name)
{
lock (random)
{
randName = name.ToLower() + Guid.NewGuid().ToString("N").Substring(0, 3)
.ToLower();
}
}

public virtual string RandomName(string prefix, int maxLen)
{
lock (random)
{
prefix = prefix.ToLower();
int num = 5;
string text = random.Next(0, 100000).ToString("D5");
if (maxLen < prefix.Length + randName.Length + num)
{
string text2 = prefix + text;
return text2 + RandomString((maxLen - text2.Length) / 2);
}

string text3 = prefix + randName + text;
return text3 + RandomString((maxLen - text3.Length) / 2);
}
}

private string RandomString(int length)
{
string text = "";
while (text.Length < length)
{
text += Guid.NewGuid().ToString("N").Substring(0, Math.Min(32, length))
.ToLower();
}

return text;
}

public string RandomGuid()
{
return Guid.NewGuid().ToString();
}
}
}
3 changes: 1 addition & 2 deletions e2etest/GuestProxyAgentTest/Utilities/VMBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Azure.ResourceManager.Network;
using Azure.ResourceManager.Resources;
using GuestProxyAgentTest.Settings;
using Microsoft.Azure.Management.ResourceManager.Fluent;

namespace GuestProxyAgentTest.Utilities
{
Expand All @@ -24,7 +23,7 @@ class VMBuilder
private string pubIpName = "";
private string rgName = "";
private string adminUsername = "testuser";
private string adminPassword = SdkContext.RandomResourceName("pP@1", 15);
private string adminPassword = new ResourceNamer("").RandomName("pP@1", 15);

// In order to use the plan, we need to accept the terms first.
// https://learn.microsoft.com/en-us/cli/azure/vm/image/terms?view=azure-cli-latest#az-vm-image-terms-accept
Expand Down
Loading