Skip to content

Commit 1286cfe

Browse files
paulmedynskibenrr101edwardnealmdaigle
authored
[5.1] Stabilize CI Pipelines (#3599)
* User Story 38467: Backport mac server name fix - Backported part of #3494 and #3591: - Added configurable test jobs timeout, defaulting to 90 minutes. - Reduced generated database names to 96 chars to try to fix macOS test failures. * User Story 38481: Fix unique db object name issues - Fixed the unique name generators to: - Keep max lengths to 30 and 96 characters respectively. - Ensure uniqueness at the start of the names. - Added link to database identifier syntax. * User Story 38481: Fix unique db object name issues - Removed DateOnly tests that aren't supported on 5.1. * Add CodeQL suppression for DefaultAzureCredential use in Production (#3542) - Adjusted CodeQL suppression to meet the strict requirements of where it may appear relative to the flagged code. - Adding catch for macOS socket error to log and ignore. * - Added back some blocks that were removed by cherry-picks. - Added console diagnostics to see when Enclave tables are dropped. * - Fixed typo in code that only gets compiled when building on Windows (eek!) * Tests | Remove hardcoded credentials from ManualTests (#3204) * Initial removal of CertificateUtility.CreateCertificate One test implied that DataTestUtility.AKVUrl would point to an RSA key which aligned with the certificate's private key. Switching this to dynamically generate the key in places. * Hotfix for Azure Key Vault tests * Removed hardcoded references to Azure Key Vault key * Removed hardcoded references to CertificateUtilityWin These were mostly related to generating CSP keys. * Code review changes * Reorder properties and constructors * Move AEConnectionStringProviderWithCspParameters to its own file * Tweak to the AKV token acquisition * Code review Redundant bracket, alphabetised the ManualTesting csproj * Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategy.cs Let's try @edwardneal's idea Co-authored-by: Edward Neal <[email protected]> * Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategy.cs Co-authored-by: Edward Neal <[email protected]> * Fixes as per @edwardneal's suggestions * Fix as per @edwardneal's suggestion * Fix missing `new` Co-authored-by: Edward Neal <[email protected]> * Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyAzureKeyVault.cs Co-authored-by: Edward Neal <[email protected]> * Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyAzureKeyVault.cs Co-authored-by: Edward Neal <[email protected]> * Address comment that we don't need a CspParameters object as part of the test arguments * Move test arguments into property (the class was only used in a single location) * Cleanup test code * Tweak default provider discovery code to handle edge cases a bit better * Address comment regarding readonly member variables Apply long line chomping * Addressing the last of the comments. --------- Co-authored-by: Edward Neal <[email protected]> * Update test utilities target frameworks. Fix compilation issues. * Construct valid X500 distinguished name. * Print rsa key type for debugging. * Clean up net version ifdefs to fix certificate exportability. --------- Co-authored-by: Benjamin Russell <[email protected]> Co-authored-by: Edward Neal <[email protected]> Co-authored-by: Malcolm Daigle <[email protected]>
1 parent ee2d196 commit 1286cfe

File tree

53 files changed

+1150
-849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1150
-849
lines changed

eng/pipelines/common/templates/jobs/run-tests-package-reference-job.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ parameters:
1717
type: string
1818
default: empty
1919

20+
# The timeout, in minutes, for this job.
21+
- name: timeout
22+
type: string
23+
default: 90
24+
2025
jobs:
2126
- job: run_tests_package_reference
2227
displayName: 'Run tests with package reference'
2328
${{ if ne(parameters.dependsOn, 'empty')}}:
2429
dependsOn: '${{parameters.dependsOn }}'
30+
31+
# Some of our tests take longer than the default 60 minutes to run on some
32+
# OSes and configurations.
33+
timeoutInMinutes: ${{ parameters.timeout }}
34+
2535
pool:
2636
type: windows # read more about custom job pool types at https://aka.ms/obpipelines/yaml/jobs
2737
isCustom: true

eng/pipelines/dotnet-sqlclient-signing-pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ parameters: # parameters are shown up in ADO UI in a build queue time
6565
- NonOfficial
6666
- Official
6767

68+
# The timeout, in minutes, for each test job.
69+
- name: testsTimeout
70+
displayName: 'Tests timeout (in minutes)'
71+
type: string
72+
default: 90
73+
6874
variables:
6975
- template: /eng/pipelines/libraries/variables.yml@self
7076
- name: packageFolderName
@@ -172,6 +178,7 @@ extends:
172178
- template: eng/pipelines/common/templates/jobs/run-tests-package-reference-job.yml@self
173179
parameters:
174180
packageFolderName: $(packageFolderName)
181+
timeout: ${{ parameters.testsTimeout }}
175182
downloadPackageStep:
176183
download: current
177184
artifact: $(packageFolderName)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,30 @@ public override uint Receive(out SNIPacket packet, int timeoutInMilliseconds)
851851
}
852852
finally
853853
{
854-
// Reset the socket timeout to Timeout.Infinite after the receive operation is done
855-
// to avoid blocking the thread in case of a timeout error.
856-
_socket.ReceiveTimeout = Timeout.Infinite;
854+
const int resetTimeout = Timeout.Infinite;
855+
856+
try
857+
{
858+
// Reset the socket timeout to Timeout.Infinite after
859+
// the receive operation is done to avoid blocking the
860+
// thread in case of a timeout error.
861+
_socket.ReceiveTimeout = resetTimeout;
862+
863+
}
864+
catch (SocketException ex)
865+
{
866+
// We sometimes see setting the ReceiveTimeout fail
867+
// on macOS. There's isn't much we can do about it
868+
// though, so just log and move on.
869+
SqlClientEventSource.Log.TrySNITraceEvent(
870+
nameof(SNITCPHandle),
871+
EventType.ERR,
872+
"Connection Id {0}, Failed to reset socket " +
873+
"receive timeout to {1}: {2}",
874+
_connectionId,
875+
resetTimeout,
876+
ex.Message);
877+
}
857878
}
858879
}
859880
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,28 @@ private static TokenCredentialData CreateTokenCredentialInstance(TokenCredential
587587
defaultAzureCredentialOptions.WorkloadIdentityClientId = tokenCredentialKey._clientId;
588588
}
589589

590-
return new TokenCredentialData(new DefaultAzureCredential(defaultAzureCredentialOptions), GetHash(secret));
590+
// SqlClient is a library and provides support to acquire access
591+
// token using 'DefaultAzureCredential' on user demand when they
592+
// specify 'Authentication = Active Directory Default' in
593+
// connection string.
594+
//
595+
// Default Azure Credential is instantiated by the calling
596+
// application when using "Active Directory Default"
597+
// authentication code to connect to Azure SQL instance.
598+
// SqlClient is a library, doesn't instantiate the credential
599+
// without running application instructions.
600+
//
601+
// Note that CodeQL suppression support can only detect
602+
// suppression comments that appear immediately above the
603+
// flagged statement, or appended to the end of the statement.
604+
// Multi-line justifications are not supported.
605+
//
606+
// https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/codeql/codeql-semmle#guidance-on-suppressions
607+
//
608+
// CodeQL [SM05137] See above for justification.
609+
DefaultAzureCredential cred = new(defaultAzureCredentialOptions);
610+
611+
return new TokenCredentialData(cred, GetHash(secret));
591612
}
592613

593614
TokenCredentialOptions tokenCredentialOptions = new() { AuthorityHost = new Uri(tokenCredentialKey._authority) };

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public void TestEncryptDecryptWithAKV()
6262
[PlatformSpecific(TestPlatforms.Windows)]
6363
public void TestRoundTripWithAKVAndCertStoreProvider()
6464
{
65-
using SQLSetupStrategyCertStoreProvider certStoreFixture = new ();
65+
SqlColumnEncryptionCertificateStoreProvider certStoreProvider = new SqlColumnEncryptionCertificateStoreProvider();
6666
byte[] plainTextColumnEncryptionKey = ColumnEncryptionKey.GenerateRandomBytes(ColumnEncryptionKey.KeySizeInBytes);
67-
byte[] encryptedColumnEncryptionKeyUsingAKV = _fixture.AkvStoreProvider.EncryptColumnEncryptionKey(DataTestUtility.AKVUrl, @"RSA_OAEP", plainTextColumnEncryptionKey);
68-
byte[] columnEncryptionKeyReturnedAKV2Cert = certStoreFixture.CertStoreProvider.DecryptColumnEncryptionKey(certStoreFixture.CspColumnMasterKey.KeyPath, @"RSA_OAEP", encryptedColumnEncryptionKeyUsingAKV);
67+
byte[] encryptedColumnEncryptionKeyUsingAKV = _fixture.AkvStoreProvider.EncryptColumnEncryptionKey(_fixture.AkvKeyUrl, @"RSA_OAEP", plainTextColumnEncryptionKey);
68+
byte[] columnEncryptionKeyReturnedAKV2Cert = certStoreProvider.DecryptColumnEncryptionKey(_fixture.ColumnMasterKeyPath, @"RSA_OAEP", encryptedColumnEncryptionKeyUsingAKV);
6969
Assert.True(plainTextColumnEncryptionKey.SequenceEqual(columnEncryptionKeyReturnedAKV2Cert), @"Roundtrip failed");
7070

7171
// Try the opposite.
72-
byte[] encryptedColumnEncryptionKeyUsingCert = certStoreFixture.CertStoreProvider.EncryptColumnEncryptionKey(certStoreFixture.CspColumnMasterKey.KeyPath, @"RSA_OAEP", plainTextColumnEncryptionKey);
73-
byte[] columnEncryptionKeyReturnedCert2AKV = _fixture.AkvStoreProvider.DecryptColumnEncryptionKey(DataTestUtility.AKVUrl, @"RSA_OAEP", encryptedColumnEncryptionKeyUsingCert);
72+
byte[] encryptedColumnEncryptionKeyUsingCert = certStoreProvider.EncryptColumnEncryptionKey(_fixture.ColumnMasterKeyPath, @"RSA_OAEP", plainTextColumnEncryptionKey);
73+
byte[] columnEncryptionKeyReturnedCert2AKV = _fixture.AkvStoreProvider.DecryptColumnEncryptionKey(_fixture.AkvKeyUrl, @"RSA_OAEP", encryptedColumnEncryptionKeyUsingCert);
7474
Assert.True(plainTextColumnEncryptionKey.SequenceEqual(columnEncryptionKeyReturnedCert2AKV), @"Roundtrip failed");
7575
}
7676

0 commit comments

Comments
 (0)