Skip to content

Conversation

@dlevy-msft-sql
Copy link
Contributor

@dlevy-msft-sql dlevy-msft-sql commented Jan 28, 2026

Problem

PR #642 added e2e tests that originally only worked with SQL authentication credentials (SQLCMDUSER/SQLCMDPASSWORD). The ADO pipeline runs tests twice with different authentication methods:

Pipeline Run Auth Method SQLCMDSERVER SQLCMDUSER SQLCMDPASSWORD
SQL2022 SQL Auth ✓ localhost ✓ sa ✓ set
SQLDB Azure AD (Service Principal) ✓ Azure SQL ✗ empty ✗ empty

Solution

Updated the e2e tests to detect and use Azure AD authentication when appropriate, matching the approach used in pkg/sqlcmd/sqlcmd_test.go:

  • Added canTestAzureAuth() - detects Azure SQL endpoint + no SQL credentials
  • Added getAuthArgs() - returns appropriate --authentication-method flag:
    • ActiveDirectoryAzurePipelines when running in Azure Pipelines
    • ActiveDirectoryDefault otherwise
  • Updated three live connection tests to use these helpers

Result

Pipeline Run With PR #642 With this PR
SQL2022 RUN ✅ RUN ✅ (SQL auth)
SQLDB RUN → FAIL ❌ RUN ✅ (Azure AD)

Tests now execute on both pipeline runs with the appropriate authentication method.

Files Changed

  • cmd/modern/e2e_test.go: Added Azure AD auth detection and --authentication-method flag support

The Azure DevOps pipeline runs tests twice:
1. SQL2022: Uses SQL auth (sa user) - tests will run
2. SQLDB: Uses Azure AD auth (service principal) - tests should skip

The live connection e2e tests require SQL auth credentials (SQLCMDUSER/SQLCMDPASSWORD)
which aren't available in the Azure AD auth scenario. Added skipIfNoSQLAuth() to
properly skip these tests instead of failing with 'Login failed for user ''.
@dlevy-msft-sql dlevy-msft-sql self-assigned this Jan 28, 2026
@dlevy-msft-sql dlevy-msft-sql added Size: S Small issue (less than one week effort) testing labels Jan 28, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes pipeline failures from PR #642 by adding proper test skipping logic for end-to-end tests that require SQL authentication credentials. The SQLDB pipeline test runs use Azure AD authentication without SQLCMDUSER/SQLCMDPASSWORD environment variables, causing these tests to fail inappropriately.

Changes:

  • Added hasSQLAuthCredentials() helper function to check for SQL authentication credentials (SQLCMDUSER and SQLCMDPASSWORD)
  • Added skipIfNoSQLAuth() helper function that skips tests when SQL authentication is not available
  • Updated three live connection tests to use the new skip function instead of just checking for SQLCMDSERVER

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@shueybubbles
Copy link
Collaborator

why can't these tests look for the same auth settings as the other tests?

Instead of skipping tests when SQL auth credentials are unavailable,
detect Azure AD authentication and use appropriate --authentication-method
flag, matching the approach used in pkg/sqlcmd/sqlcmd_test.go.

Tests now run on both SQL2022 (SQL auth) and SQLDB (Azure AD) pipelines.
@dlevy-msft-sql dlevy-msft-sql changed the title fix: skip e2e live connection tests when SQL auth credentials unavailable feat: support Azure AD auth in e2e tests Jan 28, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@dlevy-msft-sql
Copy link
Contributor Author

why can't these tests look for the same auth settings as the other tests?

It turns out there's no good reason. Fixed.

Copy link
Collaborator

@shueybubbles shueybubbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@dlevy-msft-sql dlevy-msft-sql merged commit 3620fb5 into microsoft:main Jan 28, 2026
10 checks passed
@dlevy-msft-sql dlevy-msft-sql deleted the fix/e2e-sql-auth-skip branch January 28, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: S Small issue (less than one week effort) testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants