Skip to content

Commit f89a118

Browse files
Merge branch 'master' into AlwaysEncryptedDemos
2 parents 38813d8 + 4332ce6 commit f89a118

File tree

12 files changed

+442
-108
lines changed

12 files changed

+442
-108
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# Azure Data SQL Samples Repository
44
This GitHub repository contains code samples that demonstrate how to use Microsoft's Azure Data products including SQL Server, Azure SQL Database, Azure Synapse, and Azure SQL Edge. Each sample includes a README file that explains how to run and use the sample.
55

6-
Note that certain features like In-Memory OLTP are edition specific for SQL Server and would be possible to implement if the edition which supports that feature is being used to run the sample.
6+
Please note that specific features, such as In-Memory OLTP, are edition-specific for SQL Server. These features will only be available if the edition that supports them is used to run the sample.
77

88
## Releases in this repository
99

10-
Releases allow you to conveniently download sample databases or applications without the need to build them from source code. This SQL Server samples repository has the following notable releases:
10+
Releases provide convenient downloads of sample databases and applications, eliminating the need to build them from source code. This SQL Server samples repository offers the following notable releases:
1111

1212
- [Wide World Importers sample database v1.0](https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0) is the main sample for SQL Server 2016 and Azure SQL Database. It contains both an OLTP and an OLAP database.
1313
- [In-Memory OLTP Performance Demo v1.0](https://github.com/Microsoft/sql-server-samples/releases/tag/in-memory-oltp-demo-v1.0) illustrates the performance benefits of the In-Memory OLTP technology built into SQL Server and Azure SQL Database.
@@ -16,7 +16,12 @@ Releases allow you to conveniently download sample databases or applications wit
1616
To see the complete list of resources in this repository, navigate to [Releases](https://github.com/Microsoft/sql-server-samples/releases)
1717

1818
## Working in GitHub
19-
To work in GitHub, go to https://github.com/microsoft/sql-server-samples and fork the repository. Work in your own fork and when you are ready to submit to make a change or publish your sample for the first time, submit a pull request into the master branch of sql-server-samples. One of the approvers will review your request and accept or reject the pull request.
19+
To contribute on GitHub, follow these steps:
20+
21+
- Visit https://github.com/microsoft/sql-server-samples and fork the repository.
22+
- Work in your forked repository.
23+
- When you're ready to make changes or publish your sample for the first time, submit a pull request into the 'master' branch of 'sql-server-samples'.
24+
- One of the approvers will review your request and either accept or reject the pull request.
2025

2126
Each sample should be in its own folder with a README.md file that follows the [template](README_samples_template.md). Generated files (e.g., .exe or .bacpac) and user configuration settings (e.g., .user) should not be committed to GitHub.
2227

samples/containers/unit-testing/tsqlt-docker/.github/workflows/automated-tests.yml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# This workflow installs tSQLt and runs the test units
1+
# This workflow runs the configured unit tests after installing tSQLt on a SQL Server instance inside a Docker container!
22

3-
name: tSQLt installer and unit testing runner
3+
name: Unit testing runner
4+
5+
#---------- 1. Definition of activation events
46

57
# Controls when the workflow will run
68
on:
@@ -9,16 +11,21 @@ on:
911
branches: [ "master" ]
1012
pull_request:
1113
branches: [ "master" ]
12-
14+
1315
# Allows you to run this workflow manually from the Actions tab
1416
workflow_dispatch:
1517

18+
#---------- 2. Creating a Docker container from a SQL Server image on Linux
19+
1620
jobs:
21+
1722
windows-auth-tsqlt:
18-
name: Installting tSQLt with SQL Auth
23+
24+
name: Installting tSQLt framework with SQL Auth and running unit tests
25+
1926
# The type of runner that the job will run on
2027
runs-on: ubuntu-latest
21-
28+
2229
services:
2330
sqlserver:
2431
image: chriseaton/adventureworks:latest
@@ -29,63 +36,67 @@ jobs:
2936
SA_PASSWORD: 3uuiCaKxfbForrK
3037

3138
steps:
32-
- uses: actions/checkout@v2
3339

34-
- name: Install tSQLt with SQL auth on tempdb
35-
uses: lowlydba/tsqlt-installer@v1
36-
with:
37-
sql-instance: localhost
38-
database: tempdb
39-
version: latest
40-
user: sa
41-
password: 3uuiCaKxfbForrK
42-
40+
#---------- 2.1 Save the container ID into the environment variable ENV_CONTAINER_ID
41+
4342
#- name: Get the containers list unformatted
4443
# run: docker ps
45-
44+
4645
#- name: Get the containers list formatted
4746
# run: docker ps --all --filter status=running --no-trunc --format "{{.ID}}"
48-
47+
4948
#- name: Set the container ID
5049
# run: echo '::set-output name=CONTAINER_ID::$(docker ps --all --filter status=running --no-trunc --format "{{.ID}}")'
5150
# id: ContainerID
52-
51+
5352
#- name: Get container ID
5453
# run: echo "The container ID is ${{ steps.ContainerID.outputs.CONTAINER_ID }}"
55-
54+
5655
- name: Set environment variable ENV_CONTAINER_ID
5756
run: echo "ENV_CONTAINER_ID=$(docker ps --all --filter status=running --no-trunc --format "{{.ID}}")" >> $GITHUB_ENV
5857

5958
- name: Test environment variable ENV_CONTAINER_ID
6059
run: echo $ENV_CONTAINER_ID
61-
62-
#- name: Print environment variables
63-
# run: env
6460

65-
- name: Restore AdventureWorks2017
61+
- name: Sleep for 20s
62+
uses: juliangruber/sleep-action@v1
63+
with:
64+
time: 20s
65+
66+
#---------- 3. AdventureWorks database recovery
67+
68+
- name: Restore AdventureWorks
6669
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -Q "RESTORE DATABASE [AdventureWorks2017] FROM DISK = '/adventureworks.bak' WITH MOVE 'AdventureWorks2017' TO '/var/opt/mssql/data/AdventureWorks.mdf', MOVE 'AdventureWorks2017_log' TO '/var/opt/mssql/data/AdventureWorks_log.ldf'"
6770

6871
- name: Get the database list
6972
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -Q "SELECT Name FROM sys.databases"
7073

74+
#---------- 4. Installation of the tSQLt framework
75+
76+
- uses: actions/[email protected]
77+
7178
- name: Install tSQLt with SQL auth on AdventureWorks2017
7279
uses: lowlydba/tsqlt-installer@v1
7380
with:
7481
sql-instance: localhost
7582
database: AdventureWorks2017
7683
version: latest
7784
user: sa
78-
password: 3uuiCaKxfbForrK
79-
85+
password: 3uuiCaKxfbForrK
86+
87+
#---------- 5. Creating the database objects to be tested (SUT)
88+
8089
- name: Create sp usp_Raiserror_SafetyStockLevel
8190
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/usp-raiserror-safetystocklevel.sql
82-
91+
8392
- name: Create system under test (SUT) TR_Product_SafetyStockLevel
8493
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/tr-product-safetystocklevel.sql
85-
94+
95+
#---------- 6. Creation and execution of test units
96+
8697
- name: Create test class UnitTestTRProductSafetyStockLevel
8798
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-class-trproductsafetystocklevel.sql
88-
99+
89100
- name: Create and run test case try to insert one wrong row
90101
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-one-wrong-row.sql
91102

samples/containers/unit-testing/tsqlt-docker/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ on:
9595
branches: [ "master" ]
9696
pull_request:
9797
branches: [ "master" ]
98-
98+
9999
# Allows you to run this workflow manually from the Actions tab
100100
workflow_dispatch:
101101
```
@@ -112,8 +112,11 @@ The following YAML code snippet sets up the SQL Server service.
112112

113113
```
114114
jobs:
115+
115116
windows-auth-tsqlt:
116-
name: Installting tSQLt with SQL Auth
117+
118+
name: Installting tSQLt framework with SQL Auth and running unit tests
119+
117120
# The type of runner that the job will run on
118121
runs-on: ubuntu-latest
119122
@@ -153,7 +156,7 @@ The snippet of YAML code used for the installation of the tSQLt framework in the
153156

154157
```
155158
steps:
156-
- uses: actions/checkout@v2
159+
- uses: actions/checkout@v3.5.2
157160
- name: Install tSQLt with SQL auth on AdventureWorks2017
158161
uses: lowlydba/tsqlt-installer@v1
159162
with:
@@ -177,8 +180,9 @@ Triggers and stored procedures are created in the AdventureWorks database attach
177180
```
178181
- name: Create sp usp_Raiserror_SafetyStockLevel
179182
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/usp-raiserror-safetystocklevel.sql
180-
- name: Create TR_Product_SafetyStockLevel
181-
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/tr_product_safetystocklevel.sql
183+
184+
- name: Create system under test (SUT) TR_Product_SafetyStockLevel
185+
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./source/tr-product-safetystocklevel.sql
182186
```
183187

184188
**6. Creation and execution of test units**
@@ -203,10 +207,13 @@ The following snippet of YAML code creates and runs the test units.
203207
```
204208
- name: Create and run test case try to insert one wrong row
205209
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-one-wrong-row.sql
210+
206211
- name: Create and run test case try to insert one right row
207212
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-one-right-row.sql
213+
208214
- name: Create and run test case try to insert multiple rows
209215
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-multiple-rows.sql
216+
210217
- name: Create and run test case try to insert multiple rows ordered
211218
run: docker exec -i $ENV_CONTAINER_ID /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "3uuiCaKxfbForrK" -d AdventureWorks2017 -b < ./unit-test/test-case-try-to-insert-multiple-rows-ordered.sql
212219
```

0 commit comments

Comments
 (0)