Skip to content

Commit 01d1789

Browse files
raymond13513copybara-github
authored andcommitted
Add alias for sqlcmd when installed on linux
PiperOrigin-RevId: 385205457
1 parent 111e223 commit 01d1789

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

perfkitbenchmarker/linux_packages/mssql_tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ def AptInstall(vm):
4343
location=_DEB_FILE_LOCATION))
4444
vm.RemoteCommand('sudo apt-get update')
4545
vm.RemoteCommand('sudo ACCEPT_EULA=Y /usr/bin/apt-get -y install mssql-tools')
46+
vm.RemoteCommand('echo "alias sqlcmd=\'/opt/mssql-tools/bin/sqlcmd\'"'
47+
' >> ~/.bashrc')
48+
vm.RemoteCommand('source ~/.bashrc')

perfkitbenchmarker/sql_engine_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def InstallPackages(self):
199199

200200
def MakeSqlCommand(self, command: str, database_name=''):
201201
"""See base class."""
202-
sqlserver_command = '/opt/mssql-tools/bin/sqlcmd -S %s -U %s -P %s ' % (
202+
sqlserver_command = 'sqlcmd -S %s -U %s -P %s ' % (
203203
self.connection_properties.endpoint,
204204
self.connection_properties.database_username,
205205
self.connection_properties.database_password)

tests/relational_db_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def testMakeSqlserverCommand(self):
184184
db.endpoint = '1.1.1.1'
185185
self.assertEqual(
186186
db.client_vm_query_tools.MakeSqlCommand('Select 1'),
187-
'/opt/mssql-tools/bin/sqlcmd -S 1.1.1.1 -U root -P perfkitbenchmarker -Q "Select 1"'
187+
'sqlcmd -S 1.1.1.1 -U root -P perfkitbenchmarker -Q "Select 1"'
188188
)
189189

190190
def testMakeSqlserverCommandWithLocalHost(self):
@@ -195,7 +195,7 @@ def testMakeSqlserverCommandWithLocalHost(self):
195195
db.endpoint = '1.1.1.1'
196196
self.assertEqual(
197197
db.server_vm_query_tools.MakeSqlCommand('Select 1'),
198-
'/opt/mssql-tools/bin/sqlcmd -S localhost -U root -P perfkitbenchmarker -Q "Select 1"'
198+
'sqlcmd -S localhost -U root -P perfkitbenchmarker -Q "Select 1"'
199199
)
200200

201201
def testInstallMYSQLServer(self):

0 commit comments

Comments
 (0)