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 require 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

The SQLDB run intentionally omits SQL credentials because it tests Azure AD/Entra authentication via service principal (using AZURESUBSCRIPTION_CLIENT_ID and AZURESUBSCRIPTION_TENANT_ID).

PR #642's tests used skipIfNoLiveConnection() which only checks SQLCMDSERVER. Since both runs have that set, both tried to run the tests. The SQLDB run failed with:

Login failed for user ''.

Solution

Added skipIfNoSQLAuth() helper that checks for SQL authentication credentials before running tests that require them:

  • hasSQLAuthCredentials() - checks both SQLCMDUSER and SQLCMDPASSWORD are set
  • skipIfNoSQLAuth() - chains with skipIfNoLiveConnection(), then checks SQL auth credentials

Result

Pipeline Run With PR #642 With PR #659
SQL2022 RUN ✅ RUN ✅
SQLDB RUN → FAIL ❌ SKIP ⏭️

The SQL2022 coverage is unchanged - tests still execute against a real SQL Server. Tests are skipped on SQLDB where they can't work anyway (no SQL auth credentials available).

Alternative Considered

Making the e2e tests work with Azure AD auth was considered, but these tests verify query functionality (piped input, -Q flag, input files), not authentication methods. Skipping when SQL auth isn't available is the pragmatic solution.

Files Changed

  • cmd/modern/e2e_test.go: Added SQL auth check helpers, updated 3 tests to use skipIfNoSQLAuth()

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.

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.

1 participant