Skip to content

Commit

Permalink
Adding keyvault sdk to CI pipeline (#2619)
Browse files Browse the repository at this point in the history
* adding keyvault sdk to CI pipeline

* adding keyvault sdk to CI pipeline

* adding keyvault sdk to CI pipeline

* checkstyle

* adding keyvault sdk to CI pipeline

* Replacing Thread.sleep() with SdkContext.sleep() to run tests faster in playback mode

* Renaming environment variables for CI as '.' does not work on linux

* Renaming environment variables for CI

* changing order for CI pipeline jobs

* changing order for CI pipeline jobs

* moving 'checkstyle' task to the 'Publish' job

* removing unused files
  • Loading branch information
lenala authored Nov 26, 2018
1 parent f1c6de6 commit 0d8c439
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 164 deletions.
7 changes: 6 additions & 1 deletion .azure-pipelines/client.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ parameters:

jobs:
- job: ${{ format('Test_{0}', parameters.name) }}

dependsOn:
- 'Publish'
pool:
vmImage: ${{ parameters.vmImage }}

steps:
- script: |
mvn jetty:run-forked -Dorg.slf4j.simpleLogger.defaultLogLevel=error -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode -f pom.client.xml
displayName: 'Start Jetty'
- task: Maven@3
displayName: 'Run tests'
inputs:
Expand Down
51 changes: 31 additions & 20 deletions .azure-pipelines/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,20 @@ trigger:
- master

jobs:
- template: client.test.yml
parameters:
name: Linux
vmImage: 'ubuntu-16.04'

- template: client.test.yml
parameters:
name: macOS
vmImage: 'macOS-10.13'

- template: client.test.yml
parameters:
name: Windows
vmImage: 'vs2017-win2016'

- job: 'Publish'

dependsOn:
- 'Test_Linux'
- 'Test_macOS'
- 'Test_Windows'

pool:
vmImage: 'ubuntu-16.04'

steps:
- task: Maven@3
displayName: 'Checkstyle'
inputs:
mavenPomFile: 'pom.client.build.xml'
goals: 'checkstyle:check'
options: '--batch-mode'
mavenOptions: '-Dorg.slf4j.simpleLogger.defaultLogLevel=error -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
publishJUnitResults: false
- task: Maven@3
inputs:
mavenPomFile: 'pom.client.build.xml'
Expand All @@ -40,6 +28,14 @@ jobs:
goals: 'package'
displayName: 'Package'

- task: Maven@3
displayName: 'Javadoc'
inputs:
mavenPomFile: 'pom.client.build.xml'
goals: 'javadoc:jar'
options: '-DskipTests=true'
publishJUnitResults: false

- task: CopyFiles@2
inputs:
contents: '**/*.jar'
Expand All @@ -49,3 +45,18 @@ jobs:

- task: PublishBuildArtifacts@1
displayName: 'Publish'

- template: client.test.yml
parameters:
name: Linux
vmImage: 'ubuntu-16.04'

- template: client.test.yml
parameters:
name: macOS
vmImage: 'macOS-10.13'

- template: client.test.yml
parameters:
name: Windows
vmImage: 'vs2017-win2016'
74 changes: 37 additions & 37 deletions keyvault/data-plane/jetty.xml → jetty.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory"/>
</Item>
</Array>
</Arg>
<Set name="port">11080</Set>
</New>
</Arg>
</Call>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory"/>
</Item>
</Array>
</Arg>
<Set name="port">11081</Set>
</New>
</Arg>
</Call>
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory"/>
</Item>
</Array>
</Arg>
<Set name="port">11080</Set>
</New>
</Arg>
</Call>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory"/>
</Item>
</Array>
</Arg>
<Set name="port">11081</Set>
</New>
</Arg>
</Call>
</Configure>
19 changes: 0 additions & 19 deletions keyvault/data-plane/.travis.yml

This file was deleted.

8 changes: 0 additions & 8 deletions keyvault/data-plane/azure-keyvault/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,6 @@ the MIT License. See License.txt in the project root for license information. --

<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.22.v20170606</version>
<configuration>
<jettyXml>../jetty.xml,../jetty-http.xml</jettyXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Random;
import java.util.concurrent.ExecutionException;

import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -83,9 +84,7 @@ public void keyAsyncForAsyncOperationsTest() throws Exception {
keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get();
pollOnKeyDeletion(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name());
keyVaultClient.purgeDeletedKey(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name());
if (isRecordMode()) {
Thread.sleep(20000);
}
SdkContext.sleep(20000);

KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get();
Assert.assertNotNull(restoreResult);
Expand Down Expand Up @@ -124,9 +123,7 @@ public void keyAsyncForAsyncOperationsTest() throws Exception {
Assert.assertNotNull(keyBundle);
pollOnKeyDeletion(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name());
keyVaultClient.purgeDeletedKey(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name());
if (isRecordMode()) {
Thread.sleep(20000);
}
SdkContext.sleep(20000);
// Get the unavailable key to throw exception -> it gets stuck

try {
Expand Down Expand Up @@ -183,7 +180,7 @@ public void secretAsyncForAsyncOperationsTest() throws Exception {
}
pollOnSecretDeletion(vault, secretname);
keyVaultClient.purgeDeletedSecretAsync(vault, secretname, null).get();
Thread.sleep(20000);
SdkContext.sleep(20000);
}

@Test
Expand Down Expand Up @@ -259,7 +256,7 @@ public void certificateAsyncForAsyncOperationsTest() throws Exception {
}

keyVaultClient.purgeDeletedCertificate(vault, certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext;
import org.apache.commons.codec.binary.Base64;
import org.joda.time.DateTime;
import org.junit.Assert;
Expand Down Expand Up @@ -195,7 +196,7 @@ public void createSelfSignedCertificatePkcs12ForCertificateOperationsTest() thro
}

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

/**
Expand Down Expand Up @@ -253,7 +254,7 @@ public void createSelfSignedCertificatePemForCertificateOperationsTest() throws
pollOnCertificateDeletion(getVaultUri(), certificateName);

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

/**
Expand Down Expand Up @@ -356,7 +357,7 @@ public void createCertificatePkcs12ForCertificateOperationsTest() throws Excepti
pollOnCertificateDeletion(getVaultUri(), certificateName);

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

/**
Expand Down Expand Up @@ -443,7 +444,7 @@ public void createCertificatePemForCertificateOperationsTest() throws Exception
pollOnCertificateDeletion(getVaultUri(), certificateName);

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

/**
Expand Down Expand Up @@ -497,7 +498,7 @@ public void createCsrForCertificateOperationsTest() throws Exception {
}

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

/**
Expand Down Expand Up @@ -545,7 +546,7 @@ public void certificateAsyncRequestCancellationForCertificateOperationsTest() th
keyVaultClient.deleteCertificate(getVaultUri(), certificateName);
pollOnCertificateDeletion(getVaultUri(), certificateName);
keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(20000);
SdkContext.sleep(20000);
}

/**
Expand Down Expand Up @@ -606,7 +607,7 @@ public void importCertificatePkcs12ForCertificateOperationsTest() throws Excepti
}

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(10000);
SdkContext.sleep(10000);
}

/**
Expand Down Expand Up @@ -658,7 +659,7 @@ public void certificateUpdateForCertificateOperationsTest() throws Exception {
pollOnCertificateDeletion(getVaultUri(), certificateName);

keyVaultClient.purgeDeletedCertificate(getVaultUri(), certificateName);
Thread.sleep(10000);
SdkContext.sleep(10000);
}

/**
Expand Down Expand Up @@ -694,9 +695,7 @@ public void listCertificatesForCertificateOperationsTest() throws Exception {
++failureCount;
if (e.body().error().code().equals("Throttled")) {
System.out.println("Waiting to avoid throttling");
if (isRecordMode()) {
Thread.sleep(failureCount * 1500);
}
SdkContext.sleep(failureCount * 1500);
continue;
}
throw e;
Expand All @@ -723,7 +722,7 @@ public void listCertificatesForCertificateOperationsTest() throws Exception {
keyVaultClient.deleteCertificate(getVaultUri(), toDeleteCertificateName);
pollOnCertificateDeletion(getVaultUri(), toDeleteCertificateName);
keyVaultClient.purgeDeletedCertificate(getVaultUri(), toDeleteCertificateName);
Thread.sleep(10000);
SdkContext.sleep(10000);
}
}

Expand Down Expand Up @@ -760,9 +759,7 @@ public void listCertificateVersionsForCertificateOperationsTest() throws Excepti
++failureCount;
if (e.body().error().code().equals("Throttled")) {
System.out.println("Waiting to avoid throttling");
if (isRecordMode()) {
Thread.sleep(failureCount * 1500);
}
SdkContext.sleep(failureCount * 1500);
continue;
}
throw e;
Expand Down Expand Up @@ -932,9 +929,7 @@ private static CertificateBundle pollOnCertificateOperation(CertificateOperation
CertificateOperation pendingCertificateOperation = keyVaultClient
.getCertificateOperation(getVaultUri(), certificateName);
if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) {
if (isRecordMode()) {
Thread.sleep(10000);
}
SdkContext.sleep(10000);
pendingPollCount += 1;
continue;
}
Expand Down
Loading

0 comments on commit 0d8c439

Please sign in to comment.