Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmt compute update test dependency #14731

Merged
merged 2 commits into from
Sep 4, 2020
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
3 changes: 0 additions & 3 deletions eng/versioning/external_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@ media_com.microsoft.azure:adal4j;1.2.0
# sdk\resourcemanager\azure-resourcemanager-compute\pom.xml
resourcemanager_com.jcraft:jsch;0.1.55

# sdk\resourcemanager\azure-resourcemanager-compute\pom.xml
resourcemanager_com.microsoft.azure:azure-storage;6.1.0

# sdk\storage\azure-storage-blob-cryptography\pom.xml
storage_com.microsoft.azure:azure-storage;8.4.0

Expand Down
6 changes: 3 additions & 3 deletions sdk/resourcemanager/azure-resourcemanager-compute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>6.1.0</version> <!-- {x-version-update;resourcemanager_com.microsoft.azure:azure-storage;external_dependency} -->
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.8.0</version> <!-- {x-version-update;com.azure:azure-storage-blob;dependency} -->
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,25 @@
import com.azure.resourcemanager.network.models.VirtualMachineScaleSetNetworkInterface;
import com.azure.resourcemanager.network.models.VirtualMachineScaleSetNicIpConfiguration;
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
import com.azure.resourcemanager.resources.fluentcore.utils.Utils;
import com.azure.resourcemanager.resources.models.ResourceGroup;
import com.azure.resourcemanager.resources.core.TestUtilities;
import com.azure.resourcemanager.resources.fluentcore.arm.AvailabilityZoneId;
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.storage.models.StorageAccount;
import com.azure.resourcemanager.storage.models.StorageAccountKey;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.specialized.BlockBlobClient;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -106,39 +108,32 @@ public void canUpdateVirtualMachineScaleSetWithExtensionProtectedSettings() thro
Assertions.assertTrue(keys.size() > 0);
String storageAccountKey = keys.get(0).value();

final String storageConnectionString =
String
.format(
"DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s",
storageAccount.name(), storageAccountKey);
// Get the script to upload
//
InputStream scriptFileAsStream =
VirtualMachineScaleSetOperationsTests.class.getResourceAsStream("/install_apache.sh");
// Get the size of the stream
//
int fileSize;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[256];
int bytesRead;
while ((bytesRead = scriptFileAsStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
fileSize = outputStream.size();
outputStream.close();
// Upload the script file as block blob
//
URI fileUri;
if (isPlaybackMode()) {
fileUri = new URI("http://nonexisting.blob.core.windows.net/scripts/install_apache.sh");
} else {
CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient cloudBlobClient = account.createCloudBlobClient();
CloudBlobContainer container = cloudBlobClient.getContainerReference("scripts");
container.createIfNotExists();
CloudBlockBlob blob = container.getBlockBlobReference("install_apache.sh");
blob.upload(scriptFileAsStream, fileSize);
fileUri = blob.getUri();
final String storageConnectionString = Utils.getStorageConnectionString(
storageAccount.name(), storageAccountKey, storageManager.environment());
// Get the script to upload
//
String filePath = VirtualMachineScaleSetOperationsTests.class.getResource("/install_apache.sh").getPath();
File file = new File(filePath);
InputStream inputStream = VirtualMachineScaleSetOperationsTests.class
.getResourceAsStream("/install_apache.sh");

BlobServiceClient storageClient = new BlobServiceClientBuilder()
.connectionString(storageConnectionString)
.httpClient(storageManager.httpPipeline().getHttpClient())
.buildClient();
BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient("scripts");
blobContainerClient.create();

BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("install_apache.sh")
.getBlockBlobClient();
blockBlobClient.upload(inputStream, file.length());
fileUri = new URI(blockBlobClient.getBlobUrl());
}
List<String> fileUris = new ArrayList<>();
fileUris.add(fileUri.toString());
Expand Down
Loading