0

I have few unit test cases which run on dev/test/db server. dev/test server are internal servers and behind firewall. I have added these servers in deployment groups in Azure DEVOPS.

I am getting error "remote server is not accessible" when trying to run test cases from Azure Devops. How the azure devops is connecting to remote server which is behind firewall and deploying code in release ? and what i need to do to execute these test cases to remote server.

ana
  • 37
  • 1
  • 1
  • 11

1 Answers1

0
  1. Unit tests are not supposed to access the database. Database is considered an external dependency and should be mocked. Best case scenario, if using some tool like Enity Framework you could use the support for an in-memory database for testing purposes. But even the test/in-memory database does not provide full feature support.
  2. Deployment groups is a way to optimize deployment by installing an agent on the server it self and by the tag you assign you limit deployment to specific servers. They are not setting any firewall rules that on the target server

The tests that you try execute are more of integration/regression (I know there is a lot of discussion on test naming). You need a proper test environment to execute these type of tests.

Every time you get a build agent (imagine it like roughly your "vm") and you run your tests it will try to access your database.

If you need (for specific reasons and I do not suggest that at all) to be quick and dirty you could disable the firewall rules in the test db.

Another, slightly better solution would be, if you have Self-hosted agents you can whitelist server's IP

Stelios Giakoumidis
  • 2,153
  • 1
  • 7
  • 19
  • "Unit tests are not supposed to access the database." Well. If they are database unit tests they should actually. – Datautomate Sep 12 '22 at 15:01