Unit Test Azure Cloud Services - unit-testing

I wrote a couple of visual studio unit tests to test business logic included in worker role.
My worker role publishes message to Azure topics. For this I have specified connection strings in CloudConfig.cfg & I pick up the settings using RoleEnvironment.GetConfigurationSettingValue(). Since tests run in their own app domain & not inside azure emulator. Call to those functions would obviously fail.
What are the best practices out there to handle this scenario?

Instead of using RoleEnvironment.GetConfigurationSettingValue, use CloudConfigurationManager.GetSetting. This will pick up configuration settings from appropriate config file - service configuration file if your code is running in context of a cloud service or app.config/web.config otherwise.

Related

Emulation of event-driven design in Cloud Run while developing locally?

I'm developing an application with microservice architecture running on Google Cloud Run (fully managed). I want to add communication over events to my services. As I know, the only option is to use Eventarc. I'm curious what is the best way to reproduce the event-driven design when developing locally and how to make deployment as seamless as possible.
Not familiar with Google cloud explicitly, but I assume they all work similarly. As long as you can get your code running locally, then you can still use the cloud hosted message queue / pub/sub interface from your local code.
This way you can debug and try things out on your local machine while still using the messaging / eventing infrastructure.

Why does Azure Cognitive Services SDK Speech-to-Text stop unexpectedly inside of WCF service?

I'm calling out to a Windows Communication Foundation(WCF) service with a asynchronous call from the client to kick off a Azure Cognitive Speech Service SDK (using Microsoft.CognitiveServices.Speech) instance of SpeechRecognizer. The Speech Recognizer takes two arguments;
SpeechConfig.FromSubscription(key, region)
and
AudioConfig.FromWavFileInput(fileName)
When the client calls the WCF in a development environment (localhost), SpeechRecognizer is able to recognize audio files of more than 120 minutes in length, successfully returning our RecognizedSpeech text results.
When the WCF service is deployed as a WCF Based Azure Cloud Service, SpeechRecognizer for audio files of length greater than 9 minutes seem to never enter:
recognizer.Canceled += (s, e) => {}
It appears there is no error being caught, nor no error being thrown by SpeechRecognizer. The Service seems to stop "listening" to the audio input unexpectedly.
I have tried increasing the WCF Service's <basicHttpBinding />'s <binding /> Timeout variables to one hour, as well as increasing the BufferSize variables to 2GB. No luck.
I am now questioning if i should have ever put this functionality inside of a WCF service at all...
I will provide more information as necessary! Thanks.
Update
I was able to solve this issue by extracting the Azure Cognitive Speech Service from the WCF service and into a console application(.exe). After going down this path, I recommend using a message queue inside a web service to kick off a Cognitive Service living elsewhere or simply introduce Azure Cognitive Speech Service into the client. I don't recommend my solution, hard to debug and test in production environments (only logs).

ColdFusion 11 console doesn't use Windows service wrapper to start app server

I have a ColdFusion11 environment with two app servers defined. The default cfusion server was created with a Windows system service wrapper to go along with it; the second app server, for some reason, was not.
The SC tool was later used to create a Windows service wrapper for the second app server; however, when the 2nd app server is controlled within the cfusion Enterprise Manager instance, it does not use the Windows Service wrapper to control it. Is there a configuration file I can amend that will instruct CF to invoke the Windows service wrapper to control this second service? This is particularly important as this 2nd server instance has a logon identity that must be used at startup, but if the server is restarted within the CF console, the identity is obviously not used.
In effect, I need to tell the cfusion enterprise manager to use the Windows service wrapper to control the 2nd app server instance, not to just control it directly. I'm assuming there is a configuration setting buried deep within the bowels of CF that would allow me to specify this.
I've tried searching the XML configuration files, looking for a non-obvious setting within them that might point to a startup configuration parameter, but so far have found nothing. Something must control how a secondary app server is managed, so I thought I'd ask here for some insight.
For the sake of anyone else who might encounter this situation, I've discovered the answer. It has nothing to do with changing the configuration of the application server itself.
When the ColdFusion11 administrator console is told to start an instance of another application server within the Enterprise Manager, it first queries the Windows Service Control database for a defined service of the exact name "ColdFusion 11 Application Server [AppServerName]" (without the brackets). If it finds such a service, CF automatically invokes the service wrapper and starts it. Absent that, a direct invocation of the CF instance commences.
The solution to the issue for an app server created without a Windows service wrapper is, when the 'sc' utility is invoked to create the service, to provide a service name that exactly matches the format above.

Use WSRR web service outside a web application

I have a web application mostly written by others based on JSF 2, Mybatis, Spring 3 and tens of other libraries, running on Weblogic, it works and now I have to create a distinct command line application to schedule the running of some tasks already present in the web app.
I added a class with a main method in order to maintain only one codebase with a different build process to generate an executable JAR instead of a WAR. Using Spring's ClassPathXmlApplicationContext I managed to recreate the web application context, access the database beans and use them, but I'm stuck with a WSRR call which fails.
The commands:
GraphQuery graphQuery =
(GraphQuery)DataFactory.INSTANCE.create(TypeConstants.SR_URI, TypeConstants.TYPE_GRAPHQUERY);
graphQuery.setQueryExpression("/WSRR/GenericObject[#CFT_APPLIC='DS" + param + "']");
fail with a long stack, having the root exception
Caused by: java.lang.NullPointerException
at java.util.ResourceBundle.getBundle(ResourceBundle.java:960)
at com.ibm.ws.webservices.engine.resources.ProjectResourceBundle$Context.loadBundle(ProjectResourceBundle.java:474)
at com.ibm.ws.webservices.engine.resources.ProjectResourceBundle.getBundle(ProjectResourceBundle.java:372)
at com.ibm.ws.webservices.engine.resources.ProjectResourceBundle.getBundle(ProjectResourceBundle.java:341)
at com.ibm.ws.webservices.engine.resources.MessagesConstants.<clinit>(MessagesConstants.java:93)
I found that some classes and configurations are provided at runtime by the application server, and have no idea about how to replace them outside the application server.
The IBM redbook says (pages 120-121) that is possible to access a web service using a Java client, but requires a suitable EJB runtime.
How can I replicate needed EJB parameters outside the application server? I tried to use the Eclipse debugger to follow the execution of the application and extract them, but it fails, probably because the classes are loaded by Weblogic classloader.

CruiseControl.NET run as a windows service and as a standalone process behaves differently

I have a project that is being built using CruiseControl.NET. The project contains an 'MSBuild task' that runs the build for the project and also the unit tests. The unit test in turn is just a MSBuild 'exec' task that runs an executable.
The unit test involves some .NET remoting. And when the unit tests are run through the system command prompt, the software's window opens up, tests run and the process exits.
When I force a build through the web dashboard, the build hangs at the point where the unit test starts running. The software's window does not open up, but the executable is running. If the process is killed through the task explorer, the build goes through with a 'Failure' status. This happens when I run ccnet as a windows service.
If I run CCNet directly (not as a windows service) and force a build through the web dashboard, the build and unit tests go through fine as expected. (with the window of the software opening up.)
It looks like there is a deadlock in the case where CCNet is run as a windows service. I am guessing it is related to the standard output/error streams.
Is this is known problem?
What might be the problem going on?
Any suggestions on debugging this?
How can I get around it?
(I am using CCNet version 1.4.4 SP1)
When CCNet is running as a service it is not going to have access to the display, so don't expect to see anything on the screen in this configuration. The first thing I would check is the permissions - make sure the service runs as an account that has permissions to access whatever resources you need. You also have CCNet log files, which you can find via Dashboard.
On a side note, try TeamCity instead of CCNet, its 10 years ahead.
Maybe this answer will help :
delphi windows service can't download file from internet
You should know that when running CCNet as an application (the dosbox) it uses the environment variables and all rights from the logged account. So it may connect to a server, use cached passwords, get registry variables for this account.
BUT when ran as a service, the account is the one you provided : LocalSystem for exampe, where env. varibales are not the same.
So, what you can do is to change the CCNet service account for test. Change it to your user account (with password), and I'm sure it will work better !