Commit Graph

194 Commits

Author SHA1 Message Date
Benjamin Russell
e71bcefb28 Feature: Progressive Messages (#208)
This change is a reworking of the way that messages are sent to clients from the service layer. It is also a reworking of the protocol to ensure that all formulations of query send back events to the client in a deterministic ordering. To support the first change:
* Added a new event that will be sent when a message is generated
* Messages now indicate which Batch (if any) generated them
* Messages now indicate if they were error level
* Removed message storage in Batch objects and BatchSummary objects
* Batch objects no longer have error state
2017-01-10 16:42:03 -08:00
Leila Lali
379decf4e9 added support for QUOTED_IDENTIFIER in auto complete list (#190)
*  added support for QUOTED_IDENTIFIER in auto complete list
2017-01-04 14:03:10 -08:00
Connor Quagliana
3ad7cc1a8b Move Integration Tests to dedicated project (#201)
Add IntegrationTests project. Move all tests ifdef'd with LIVE_CONNECTION_TESTS to IntegrationTests project. Delete files that have no remaining code. Update codecoverage.bat to run integration tests
2017-01-04 11:37:57 -08:00
Karl Burtram
5b41538d22 Turning off a broken test until a fix can be merged (#207) 2017-01-03 13:28:48 -08:00
Benjamin Russell
7ea1b1bb87 Move Save As to ResultSet (#181)
It's an overhaul of the Save As mechanism to utilize the file reader/writer classes to better align with the patterns laid out by the rest of the query execution. Why make this change? This change makes our code base more uniform and adherent to the patterns/paradigms we've set up. This change also helps with the encapsulation of the classes to "separate the concerns" of each component of the save as function. 

* Replumbing the save as execution to pass the call down the query stack as QueryExecutionService->Query->Batch->ResultSet
    * Each layer performs it's own parameter checking
        * QueryExecutionService checks if the query exists
        * Query checks if the batch exists
        * Batch checks if the result set exists
        * ResultSet checks if the row counts are valid and if the result set has been executed
    * Success/Failure delegates are passed down the chain as well
* Determination of whether a save request is a "selection" moved to the SaveResultsRequest class to eliminate duplication of code and creation of utility classes
* Making the IFileStream* classes more generic
    * Removing the requirements of max characters to store from the GetWriter method, and moving it into the constructor for the temporary buffer writer - the values have been moved to the settings and given defaults
    * Removing the individual type writers from IFileStreamWriter
    * Removing the individual type writers from IFIleStreamReader
* Adding a new overload for WriteRow to IFileStreamWriter that will write out data, given a row's worth of data and the list of columns
* Creating a new IFileStreamFactory that creates a reader/writer pair for reading from the temporary files and writing to CSV files
* Creating a new IFileStreamFactory that creates a reader/writer pair for reading from the temporary files and writing to JSON files
* Dramatically simplified the CSV encoding functionality
* Removed duplicated logic for saving in different types and condensed down to a single chain that only differs based on what type of factory is provided
* Removing the logic for managing the list of save as tasks, since the ResultSet now performs the actual saving work, there's no real need to expose the internals of the ResultSet
* Adding new strings to the sr.strings file for save as error messages
* Completely rewriting the unit tests for the save as mechanism. Very fine grained unit tests now that should cover majority of cases (aside from race conditions)


* Refactoring maxchars params into settings and out of file stream factory

* Removing write*/read* methods from file stream readers/writers

* Migrating the CSV save as to the resultset

* Tweaks to unit testing to eliminate writing files to disk

* WIP, moving to a base class for save results writers

* Everything is wired up and compiles

* Adding unit tests for CSV encoding

* Adding unit tests for CSV and Json writers

* Adding tests to the result set for saving

* Refactor to throw exceptions on errors instead of calling failure handler

* Unit tests for batch/query argument in range

* Unit tests

* Adding service integration unit tests

* Final polish, copyright notices, etc

* Adding NULL logic

* Fixing issue of unicode to utf8

* Fixing issues as per @kburtram code review comments

* Adding files that got broken?
2016-12-21 17:52:34 -08:00
Benjamin Russell
1e59166147 Event Flow Validator (#199)
This is a reworking of the unit tests to permit us to better test events from the service host. This new Event Flow Validator class allows creating a chain of events that can then be validated after execution of the request. Each event can have its own custom validation logic for verifying that the object sent via the service host is correct. It also allows us to validate that the order of events are correct.

The big drawback is that (at this time) the validator cannot support asynchronous events or non-determinant ordering of events. We don't need this for the query execution functionality despite messages being sent asynchronously because async messages aren't sent during unit tests (due to the db message event only being present on SqlDbConnection classes). If the need arises to do async or out of order event validation, then I have some ideas for how we can do that.

* Applying the event flow validator to the query execution service integration tests

* Undoing changes to events that were included in cherry-picked commit

* Cleaning up event flow validation to query execution

* Add efv to cancel tests

* Adding efv to dispose tests

* Adding efv to subset tests

* Adding efv to SaveResults tests

* Copyright
2016-12-20 11:59:03 -08:00
Benjamin Russell
0f19de38fb Date & Time Type Fixes (#196)
This basically is a replacement to the fix for Adding Milliseconds to DateTime fields. I didn't take into consideration that `DATE` columns would report as DateTime type. Date columns have a numeric scale set to 255, leading to the formatting string for the date time to include 255 millisecond places, which is invalid.

This change also reverses the change to store DateTime precision in the buffer file. Instead, the column metadata is now used when deserializing the rows from the db. `DATETIME` and `DATETIME2` columns are differentiated by their numeric scale while `DATE` columns are differentiated by their datatype name field.

More unit tests were added. Additionally, this fixes an unreported bug that `DATE` columns were being displayed with times, which is incorrect.

* Revert "Adding Milliseconds to DateTime fields (#173)"

This reverts commit 431dfa4156.

* Reworking the reader to use the column metadata for date types

* DbColumn -> DbColumnWrapper

* Fina tweaks to support DATETIME2(0)

* Removing the unused arguments
2016-12-20 11:22:00 -08:00
Connor Quagliana
ba12a80fbf Add fix for SendEvent causing test to fail (#195)
Add flag in ServiceHost to ignore SendEvent errors
2016-12-19 14:01:03 -08:00
Aditya Bist
1a2e802a5d Merge pull request #191 from Microsoft/customerIssue/escapeReservedWordsAutocomplete
reserved words with brackets in autocomplete
2016-12-19 11:25:18 -08:00
Aditya Bist
cde7bd49b3 added tests for new scenario 2016-12-19 10:53:20 -08:00
Benjamin Russell
0bee0147d9 Revert "Adding Milliseconds to DateTime fields (#173)" (#197)
This reverts commit 431dfa4156.
2016-12-16 16:37:32 -08:00
Connor Quagliana
319c5ef7ed Merge pull request #193 from Microsoft/bug/addGetSignatureHelpTest
Add positive test for GetSignatureHelp
2016-12-16 11:08:34 -08:00
Karl Burtram
0d101cf598 Add text utils unit tests and parameter comments. (#192)
* Add unit tests for PositionOfCursor

* Add unit tests for PositionOfCursor
2016-12-15 14:22:39 -08:00
Connor Quagliana
2db585ad63 Removed #define 2016-12-15 13:46:25 -08:00
Connor Quagliana
b5cd9d6359 Changed line parameter to zero-indexed 2016-12-15 13:45:29 -08:00
Sharon Ravindran
5d2bf7fbe4 Feature/delete peek scripts (#174)
* Delete temp script folder

* Delete folder and refactor code

* Add unit tests

* create folder per workspace

* Refactor and move creation to FileUtils

* Separate multiple assignment
2016-12-15 13:34:33 -08:00
Connor Quagliana
d5de4c8b21 Merge branch 'dev' into bug/addGetSignatureHelpTest 2016-12-15 12:01:00 -08:00
Connor Quagliana
2f1debc7c9 Added positive test for GetSignatureHelp 2016-12-15 11:40:10 -08:00
Sharon Ravindran
9c6162282a Add error handling for Azure Exceptions (#177)
* Add error handling for Azure Exceptions

* Add SRGen for string

* Add specific exception messages

* Move DefinitionResult class

* Add SqlLogin constant

* Add error scenarios

* revert timeout duration

* Modify tests

* Modify tests

* Add tests

* Revert live connection definition

* Modify DefinitionsHandlerWithNoConnectionTest

* fix test after merge

* Code review changes

* Code review changes

* Code review changes
2016-12-14 16:04:47 -08:00
Karl Burtram
6f15ac0b8f Don't call SR generated constructors (#189) 2016-12-14 14:35:45 -08:00
Kevin Cunnane
0bb1c39052 Revert NetCore target to 1.0.0 to fix Jenkins (#188)
* Revert NetCore target to 1.0.0 to fix Jenkins
- Changing to 1.* ends up requiring .Net Core 1.1 to be install on the machine. We need a better solution that can work around this and let us stay on 1.0 for now. Checking in to unblock builds, will fix Travis CI later.

* Installing dotnet as part of Travis setup. There is a build in dotnet: argument that uses dotnet-install scripts and supports specific version installation
2016-12-14 14:10:10 -08:00
Karl Burtram
dd41e0545a Add tests to improve code coverage (#187)
* DbColumn and ReliableConnection tests

* More retry connection tests

* More tests

* Fix broken peek definition integration tests

* Fix test bug

* Add a couple batch tests

* Add some more tests

* More tests for code coverage.

* Validation and Diagnostic tests

* A few more tests

* A few mote test changes.

* Update file path tests to run on Windows only
2016-12-14 13:49:42 -08:00
Leila Lali
e9398f7182 Sending status change notifications from server (#186)
* Sending status change notifications from server
2016-12-14 13:19:02 -08:00
Anthony Dresser
d950b751d8 Coveralls + AppVeyor + Travis CI (#171)
* added build files

* changed build script

* revert dotnet version to older one

* added osx building

* added appveyor build

* added ruby upload code coverage

* added gulp cli to downloads

* added gulp util to deps

* added through2 to deps

* added cask install for dotnet

* added coveralls gem install to appveyor

* fixed ruby script

* change upload to be gulp

* updated call

* added test for nin

* testing

* testing

* testing

* added coveralls nuget

* echoed path

* added code coverage badge

* updated cmd

* fixed syntax error

* added dotnet to path

* added manual call to dotnet

* iterate

* change directory

* commit

* added start to dotnet core version

* changed appveyor

* updated dotnet versions

* updated readme

* removed unnec de

* customize for microsoft

* specified encrypted key in appveyor

* updated readme; added newlines

* added branches to ymls

* updated ymls
2016-12-13 11:30:30 -08:00
Karl Burtram
df9e207e5f Bump SMO to 140.1.12 to pickup Azure DB fixes (#183) 2016-12-12 22:55:26 -08:00
Leila Lali
68a83814d5 fixed the broken perf test (#180)
* fixed the broken perf test
2016-12-12 16:23:33 -08:00
Connor Quagliana
40c1434745 Fixed null ref exception in GetSignatureHelp (#175)
- Fixed a few places where ScriptParseInfo was being used before it was verified to be non-null
- Added 1 basic test for GetSignatureHelp scenario
2016-12-09 15:18:08 -08:00
Benjamin Russell
431dfa4156 Adding Milliseconds to DateTime fields (#173)
This is a slightly larger change than anticipated due the difference between `DATETIME`, `DATETIME2`, and `DateTime`. The `DATETIME` type always uses 3 decimal points of a second, while the `DATETIME2` type has 7 (although since `DATETIME2(7)` is default in SSMS suggesting that it is a variable precision type). Regardless of the db type, the engine returns `DateTime` C# type. The db types are only made visible via the column info, via the numeric precision and numeric scale. My findings were as such:
`DATETIME `: Precision = 23, Scale = 3
`DATETIME2`: Precision = 255, Scale = 7

The scale corresponds neatly with the number of second decimal points to show. The buffer file writer was modified to store both the scale and the number of ticks. Then the buffer file reader was modified to read in the precision and the number of ticks and generate the ToString version of the DateTime to add "f" as many times as there is scale, which corresponds to milliseconds.

* Code for writing milliseconds of datetime/datetime2 columns

* Adding unit tests

* Fixing potential bug with datetime2(0)
2016-12-09 12:46:17 -08:00
Leila Lali
0b295e78c2 adding a new event for when definition is requested (#167)
* sending telemetry events for intellisense usage
2016-12-08 14:05:42 -08:00
Benjamin Russell
54f30887cc Batch Start Notification (#169)
This change is part of the progressive results code. It will submit a notification from the service layer to indicate when execution of a batch has completed. This notification will contain the selection for batch, execution start time, and its ID. This will enable the extension to produce a header for the batch before the batch completes, in order to make it more clear to the user that execution is going on.

* Adding new event for batch start

* Unit tests

* Fixing comments as per @kevcunnane
2016-12-08 11:23:08 -08:00
Sharon Ravindran
ab97948005 Fix/peek def mac (#170)
* Fix Integrated auth error and Uri for *nix/Mac

* Format code

* Add Logging and unit tests

* Modify tests for Windows:

* Workaround missing default schema on *nix and Mac

* Add unit tests

* Correct comments

* Change loop length

* Fix Log message
2016-12-07 16:52:35 -08:00
Leila Lali
379c6170b3 Intellisense for when the text starts with bracket (#164)
* Intellisense for when the text starts with bracket
2016-12-06 10:09:50 -08:00
Mitchell Sternke
439845eb0a Testing code coverage fix (#168) 2016-12-05 14:05:43 -08:00
Mitchell Sternke
b5efa69ffc Fixing code coverage to work properly (#165)
* Fixing code coverage to work properly

* Added comment to comment-out
2016-12-02 15:21:59 -08:00
Sharon Ravindran
82a7a01304 Peek definition support for tables, views and stored procedures (#160)
* Add support for peek/go to definition
Add unit tests for definition

Microsoft/vscode-mssql#253 and Microsoft/vscode-mssql#268

* Format Strings

* Add integration tests

* Refactor variable names

* Remove test file

* Remove LIVE_CONNECTION definition

* Change method name

* Write files to a separate directory

* Refactor GetDefinition

* Remove unnecessary whitespace and modify variable name

* Check intellisense settings

* Refactor code to be scalable and modify tests

* Refactor to facilitate CodeGen

* Reorder methods

* Modify method to strip bracket syntax

* Add one_second constant

* Add comments

* Modify null check

* Modify GetSchema code to account for spaces

* Alter variable names and modify null checks

* Remove timeout callback and refactor null check

* remove LIVE_CONNECTION_TEST definition
2016-12-02 12:16:21 -08:00
Mitchell Sternke
dd3592fe30 Disabling broken tests to try fix code coverage build (#163) 2016-12-01 16:24:31 -08:00
Mitchell Sternke
c95933b7e1 Implemented function signature help, and added tests (#153)
* Implemented function signature help, and added tests

* Incremental commit of changes from code review feedback

* Rename test

* Added check to make sure intellisense is enabled

* Use HoverTimeout instead of BindingTimeout
2016-11-30 14:22:48 -08:00
Leila Lali
453ff9de15 Perf Test fixing bugs and Update command (#155)
* Fixed some bugs caused by rafactoring

* Verifying a test db is created before running the tests
2016-11-30 12:56:48 -08:00
Mitchell Sternke
d1b791805a Fixed issue where no-op queries would never complete (#157)
* Fixed issue where no-op queries would never complete

* Changed approach to solving the race condition with no-op queries

* Addressing feedback
2016-11-28 14:28:05 -08:00
Benjamin Russell
7de742bfab Fixing race condition in unit test (#161) 2016-11-23 13:34:48 -08:00
Benjamin Russell
d9efb95386 Progressive Results Part 2: Result Completion Event (#134)
The main change in this pull request is to add a new event that will be fired upon completion of a resultset but before the completion of a batch. This event will only fire if a resultset is available and generated.

Changes:
* ConnectionService - Slight changes to enable mocking, cleanup 
* Batch - Moving summary generation into ResultSet class, adding generation of ordinals for resultset and locking of result set list (which needs further refinement, but would be outside scope of this change)
* Adding new event and associated parameters for completion of a resultset. Params return the resultset summary
* Adding logic for assigning the event a handler in the query execution service
* Adding unit tests for testing the new event /making sure the existing tests work
* Refactoring some private properties into member variables

* Refactor to remove SectionData class in favor of BufferRange

* Adding callback for batch completion that will let the extension know that a batch has completed execution

* Refactoring to make progressive results work as per async query execution

* Allowing retrieval of batch results while query is in progress

* reverting global.json, whoops

* Adding a few missing comments, and fixing a couple code style bugs

* Using SelectionData everywhere again

* One more missing comment

* Adding new notification type for result set completion

* Plumbing event for result set completion

* Unit tests for result set events

This includes a fairly substantial change to create a mock of the
ConnectionService and to create separate memorystream storage arrays. It
preserves more correct behavior with a integration test, fixes an issue
where the test db reader will return n-1 rows because the Reliable
Connection Helper steals a record.

* Adding locking to ResultSets for thread safety

* Adding/fixing unit tests

* Adding batch ID to result set summary
2016-11-22 17:37:27 -08:00
Benjamin Russell
0841ad7cf4 Removing the FileStreamWrapper as it is unecessary (#156) 2016-11-22 17:21:41 -08:00
Mitchell Sternke
2e3bd3ae27 Feature/more tests (#154)
* First batch of new tests for increasing code coverage

* Fix for merge

* Added comments to tests
2016-11-22 09:55:15 -08:00
Benjamin Russell
db1e4ae351 Fix Code Coverage (#151)
This is another large code review. I want to make a few more changes, but since these changes will stand on their own, I'll hold back on making this change set any larger than it already is.
Changes in this request:
To address Microsoft/vscode-mssql#326, instead of doing taskkill on the service layer when WaitForExit is executed, we now make an educated guess at which service layer was spawned when the test starts and do a Process.Kill on it when we shut down the test.
All the perf tests have been moved into a new project. This was done to keep them easily separated from code coverage test runs. At the same time the perf tests were separated into separate classes for logical categorization. This process will likely be repeated on the stress tests. The tests can still easily be ran from Visual Studio Test Explorer
To address Microsoft/vscode-mssql#349, a new SelfCleaningFile class was created to allow for easy cleanup of temporary files generated for integration tests via using blocks.
Due to some of the refactoring done while moving the perf tests to a new project, the TestBase class had to be switched to more of a helper class style. As such, all tests that use inherit from TestBase now create a TestBase object on start via a using block. This also simplifies the cleanup at the end of the test.

* Solution for hanging code coverage runs

Code coverage runs would hang in certain scenarios if a test failed before
the service process could be spawned. The taskkill command would fail to
find the service process. The test would then wait for opencover to exit,
but it would not since the service process it had spawned would still be
running, causing the test run to hang indefinitely.

Solution was to capture the service process after it launched and
explicitly kill it when shutting down the test driver.

* Setting the test name in the propery in the class and removign the parameter from each method

* New project for perf tests

* Reworking integration tests to cleanup temp files

* Changes as per @llali review comments

* Adding copyright notices
* Renaming TestBase => TestHelper
* Renaming SelfCleaningFile => SelfCleaningTempFile
* Removing code that sets TestName property

* Fixing compilation error due to removed code
2016-11-18 17:46:56 -08:00
Leila Lali
c2ffd4c2a5 Setting the test name in the property in the class (#147)
Using CallerMemberName attribute to get the test name for generating the test result instead of having a name passed as a parameter for each test method
2016-11-16 11:39:48 -08:00
Mitchell Sternke
5a5f197276 Removed unneeded broken test (#150) 2016-11-15 17:57:03 -08:00
Mitchell Sternke
2211bd0403 Added notification for when language service is done updating after connect (#146)
* Added notification for when language service is done updating after connect

* Addressing feedback

* Added unit test
2016-11-15 17:39:17 -08:00
Leila Lali
0d111d9316 Fix/performancetests (#144)
* some bug fixes and improvements for perf tests. If the test name file cannot be found just use the settings.json
2016-11-14 10:10:23 -08:00
Leila Lali
80a847ff4f some bug fixes in pref tests 2016-11-11 10:07:55 -08:00
Mitchell Sternke
66afdb5fc3 Added return code to test driver (#143) 2016-11-10 11:49:08 -08:00