How to create webpack 'bundle.js' with different websocket port for SpringBootTest - selenium

I'm running Spring Boot on the backend on port 8080 and a typescript application in the browser that needs to communicate with the server via WebSocket, also via http://localhost:8080
I also have a #SpringBootTest Selenium Integration Test to test the web app, but currently I am forced to shut down the running development server before running the Selenium Test, because otherwise the test complains that port 8080 is already in use.
I'm using frontend-maven-plugin to bundle the typescript code into bundle.js with webpack --mode production. bundle.js lives inside src/main/resources/static and contains a references to http://localhost:{port} for the websocket. the {port} number is currently replaced inside bundle.js thanks to an environment variable available to webpack during the build of bundle.js.
I'm using maven-surefire-plugin to run the #SpringBootTest.
Now, my question is, how can I have mvn package both:
create the regular bundle.js with port 8080 for use in both development and production,
AND at the same time run the SpringBootTest with port 8081 for both the server and the selenium browser/websocket?
Or, what alternative configuration would you choose to allow you to run the server on port 8080 during development, and sporadically also run the whole mvn clean package without needing to first shut down the development server to avoid getting an error that port 8080 is already in use?

Related

Unable to setup multiple instances of symmetricDS on a vm

Please I have two instances of symmetricds running on my vm using the commands:
bin/sym --port 9000
bin/sym --port 4000
but I want to be able to run both instances through the linux service. I have tried installing the service using 'bin/sym_service install' in the respective directories. But it's not working and when I try to start the server I get an error stating that the port is in use.
How can I set up the linux service to use different ports?
To run multiple services of SymmetricDS on the same machine, you will need to:
Set unique port numbers for http, https, and jmx in conf/symmetric-server.properties.
Set unique service name for wrapper.name in conf/sym_service.conf
Then you can run "bin/sym_service install" to install the init script. On a side note, consider if it makes sense to run multiple nodes inside the same instance by placing multiple engine.properties files in the "engines" directory.
Find out which program is listening to the used port and kill it with kill -9 PROCESS_NUMBER. Then try again.
To run on a different port execute bin/sym --port 3000 server as stated in symmetricds.org/doc/3.10/html/user-guide.html#_sym_launcher

How to install dev certs and run as HTTPS on non-dev machine?

I am publishing my ASP.NET Core 2.2 to a local location, then zipping it and trying to run on another machine. The other machine when launching does not show listening on HTTPS, only HTTP.
This is making the app not work. Locally on my dev machine I get both endpoints. I understand that I have to possibly use dotnet dev-certs https --trust or similar command but since my build is self-contained I really do not want to install the .NET Core SDK on every machine I run this on just to get that command.
How can I make my app run with endpoint on the other machine with the least hassle?
Update:
The following message is also shown in the launch console window:
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.

IntelliJ Websphere Server Local, Error running 'Local Deploy': Address localhost:9080 is already in use

I seem to be doing something wrong in my run configuration for IntelliJ. I cannot run the server on the port 9080 because another app has to use the port 9080 and it's not up to me what port that app uses. So please don't tell me to kill the app using the port 9080. This is not a duplicate of this
With the other app running I can start up the server via command line or using an external tool in IntelliJ however I cannot start it though a run configuration. My server requires the other app to be running locally to do local testing however I cannot debug the app due to this extremely annoying issue. IntelliJ is simply picking the port 9080 out of some configuration and checking that port all on its own and deciding to not try starting the server and then somehow at some point deciding to check the port which of course wont be available. Is there a setting that I'm missing or is there another way to handle this so that way I don't run into this issue?
In local deploy there is not an option to change the port number.
From #Andrey's comments the solution turned out to be the server.xml is all that IntelliJ checks and doesn't load the bootstrap.properties right off the get go. So if you are filling in the httpPort number via bootstrap.properties, server.env, or any dynamically loaded properties, IntelliJ will use the default 9080. The solution here was then to simply hardcode the httpPort in <httpEndpoint httpPort=9081 ... /> for local testing

Attaching IntelliJ IDEA debugger to Wildfly Docker image started by Arquillian

I'm trying to create Arquillian unit test using http://arquillian.org/arquillian-cube extension where you can set a breakpoint on the server side.
I've created a project which executes a simple test successfully (all details are here):
https://github.com/scetix/arquillian-cube-wildfly-quickstart
Is there any way of automatically attaching IntelliJ IDEA debugger to Wildfly running in Docker container when the test starts?
Automatically, I don't think so. In case of the Docker example, from the point of view of the IDE that is considered a remote server.
So what you need to do is first of all start Wildfly with debug enabled (http://tools.jboss.org/blog/2015-03-17-debugging-an-externally-launched-wildfly.html) and expose the debugger port correctly (https://github.com/scetix/arquillian-cube-wildfly-quickstart/blob/master/src/test/resources/Dockerfile#L12). Put these lines into you Dockerfile:
# Expose JBoss/Wildfly management port
EXPOSE 9990
# Expose JBoss/Wildfly debug port
EXPOSE 8787
You also need to set the port binding for Docker Compose (https://github.com/scetix/arquillian-cube-wildfly-quickstart/blob/master/src/test/resources/docker-compose.yml#L5). Add port 8787 for the debugger to the YAML file (first number - 58787 here - may be any number you prefer):
ports:
- 58787:8787/tcp
And finally start IntelliJ as a remote debugger, setting the IP of the Docker host (localhost in case of native Docker, Docker Machine IP in case of Docker Machine).
You can see how to do this with IntelliJ: http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/. The example is for Tomcat; specify JBoss instead.

Unit Testing Embedded Glassfish on Cloudbees

My REST application loads an embedded Glassfish before executing TestNG tests (actually make HTTP connection to REST resources). My questions are:
If I build the application on Cloudbees, will Jenkins for CI work?
Will Jenkins still run embedded Glassfish over port 8080, and execute tests using the HTTP protocol?
you should not rely hard-coded port 8080 but use a dynamically assigned port (you can use jenkins port allocator plugin). Maven also can provide such a random free port using build-helper plugin if you use it for building.