我有一个Azure管道,它拒绝运行我的集成测试(在运行测试之前,它必须从.bak文件创建必要的数据库--这是失败的部分)
此SQL作为我的MSTest ClassInitialize例程的一部分被调用:
IF DB_ID('saleslogix_full') IS NOT NULL
BEGIN
ALTER DATABASE [saleslogix_full] SET SINGLE_USER WITH
ROLLBACK IMMEDIATE;
DROP DATABASE [saleslogix_full];
END
restore database saleslogix_full
from disk = 'C:\x\y\z\data-snapshots\saleslogix_full.bak' with Recovery,
move 'saleslogix_full' to 'C:\x\y\z\saleslogix_full.mdf',
move 'saleslogix_full_log' to 'C:\x\y\z\saleslogix_full_log.ldf'通过连接到(localdb)\MSSQLLocal服务器的“主”数据库来调用上述内容。同样,运行Visual 2019的“在我的机器上工作”。但是,这些Azure代理中的任何一个都不起作用:windows-2019和vs2017-win2016
其他详细信息- Azure代理日志片段
A total of 6 test files matched the specified pattern.
X SeededSuccessfully_SalesforceIntegration
Error Message:
Class Initialization method MyCorp.Data.ReplicationWorker.Tests.Test1.ClassInit threw exception. System.Data.SqlClient.SqlException: System.Data.SqlClient.SqlException: Cannot create more than one clustered index on table 'dbo.sysschemaarticles'. Drop the existing clustered index 'PK_dbo.sysschemaarticles' before creating another.
Database 'saleslogix_full' was restored, however an error was encountered while replication was being restored/removed. The database has been left offline. See the topic MSSQL_ENG003165 in SQL Server Books Online.
RESTORE DATABASE is terminating abnormally.
Processed 1120 pages for database 'saleslogix_full', file 'saleslogix_full' on file 1.
Processed 2 pages for database 'saleslogix_full', file 'saleslogix_full_log' on file 1..现在,埋在上面的日志消息中的宝石是:Cannot create more than one clustered index on table 'dbo.sysschemaarticles'. Drop the existing clustered index 'PK_dbo.sysschemaarticles' before creating another
在我深入研究如何做到这一点之前,谁能告诉我为什么这在我的Windows 10框上工作,而不是我的Azure管道代理呢?我最初的直觉是说这是"localdb“SQL版本的不同之处
发布于 2020-01-28 02:51:50
最后,我在我的try{...}catch{..}代码周围放置了一个.NET代码,负责轰炸SQL语句。
捕获是特定于System.Data.SqlClient.SqlException错误的。
在捕获范围内,我执行以下SQL:
"ALTER DATABASE saleslogix_full SET ONLINE"而且我所有的集成测试似乎都通过了对数据库的测试
https://serverfault.com/questions/1000361
复制相似问题