Skip to content

Commit

Permalink
test: Fix integration tests (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptiurin authored Sep 5, 2024
1 parent f63ca46 commit ea883c4
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up .NET 6.0
id: dotnet-setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up .NET 6.0
id: dotnet-setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up .NET 6.0
id: dotnet-setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ jobs:
fi
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up .NET 6.0
id: dotnet-setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
needs: integration-tests
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PAT }}
Expand All @@ -42,7 +42,7 @@ jobs:
shell: bash

- name: Checkout release action repo
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: firebolt-db/action-python-release
path: release_action
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:

- name: Set up .NET 6.0
id: dotnet-setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up .NET 6.0
id: dotnet-setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0

Expand Down
12 changes: 11 additions & 1 deletion FireboltDotNetSdk.Tests/Integration/ConnectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,17 @@ private void SetConnectionStringFirstGoodThenWrong<E>(string connString1, string
DbConnection connection = new FireboltConnection(connString1);
connection.Open();
assertSelect(connection.CreateCommand());
Assert.Throws<E>(() => connection.ConnectionString = connString2);
System.Exception? e = null;
try
{
connection.ConnectionString = connString2;
}
catch (System.Exception exception)
{
connection.Close();
e = exception;
}
Assert.That(e, Is.InstanceOf<E>());
}

private void assertSelect(DbCommand command)
Expand Down
23 changes: 12 additions & 11 deletions FireboltDotNetSdk.Tests/Integration/SystemEngineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,21 @@ public void SelectUsingSystemEngineTest()
var command = CreateCommand("CREATE TABLE IF NOT EXISTS dummy(id INT)");
command.ExecuteNonQuery();
command = CreateCommand("SELECT * FROM dummy");
string errorMessage = ((FireboltException?)Assert.Throws(Is.InstanceOf<FireboltException>(), () => { command.ExecuteNonQuery(); }))?.Response ?? "";
Assert.True(new Regex("Run this (query|statement) on a user engine.").Match(errorMessage).Success);
}
finally
{
string errorMessage = "";
try
{
CreateCommand("DROP TABLE dummy").ExecuteNonQuery();
command.ExecuteNonQuery();
}
catch (FireboltException) { };
catch (FireboltException e)
{
errorMessage = e.Message;
}
Assert.That(new Regex("Run this (query|statement) on a user engine.").Match(errorMessage).Success, Is.True);

}
finally
{
CreateCommand("DROP TABLE IF EXISTS dummy").ExecuteNonQuery();
}
}

Expand Down Expand Up @@ -337,10 +342,6 @@ public void ConnectToAccountWithoutUser()

string clientId = reader.GetString(1);
string clientSecret = reader.GetString(2);
if (string.IsNullOrEmpty(clientId)) // Currently this is bugged so retrieve id via a query. FIR-28719
{
clientId = (string)CreateCommand($"SELECT service_account_id FROM information_schema.service_accounts WHERE service_account_name='{sa_account_name}'").ExecuteScalar()!;
}
string connectionString = ConnectionString(new Tuple<string, string?>[]
{
Tuple.Create<string, string?>(nameof(ClientId), clientId),
Expand Down

0 comments on commit ea883c4

Please sign in to comment.