Performance Tests With Vaadin 14 (migrate code from Vaadin 8)

B"H

Hi,

Basically I look for createConnectorId signature use to be in VaadinSession in version 8.

this code I used to override VaadinSession in performance servlet. this keeps connector ids to be static and allow to run heavy performance test with multiply users use e.g. Load Runner tool.

All my components have id, so I use it to generate meaningful connector ids.

@SuppressWarnings("serial")
	public static class PerformanceSession extends VaadinSession {
		Map<String, Integer> staticId = Maps.newHashMap();
		int i=0;
		public PerformanceSession(VaadinService service) {
			super(service);
		}

		@Override
		public String createConnectorId(ClientConnector connector) {
			String prefix = super.createConnectorId(connector);
			String theId = createIdFromConnector(connector);
			if(theId != null){
				Integer integer = staticId.get(theId);
				if(integer == null){
					integer = new Integer(0);
				}else{
					integer++;
				}
				staticId.put(theId, integer);
				return theId += "~"+ integer +"~";
			}
			return prefix;
		}

		private String createIdFromConnector(ClientConnector connector) {
			if (connector instanceof Component) {
				Component component = (Component) connector;
				if(component.getId() != null){
					return component.getId();
				}
			}
			ClientConnector ancestor = connector.getParent();
			while((ancestor != null && !(ancestor instanceof Component)) || (ancestor != null && ((Component)ancestor).getId() == null) ){
				ancestor = ancestor.getParent();
			}
			if(ancestor != null && ancestor instanceof Component){//TODO verify this solve popup menu, check null exception etc
				Component component = (Component) ancestor; 
				if(component != null && component.getId() != null){
					return connector.getClass().getName() +"<-"+component.getId();
				}
			}
			if(ancestor == null){
				return connector.getClass().getName();
			}
			return connector.getClass().getName() + "<-"  + String.valueOf(ancestor.getClass().getName());
		}

while trying to migrate I wonder where the connector Ids are today. As data content seems to be same and contain relevant connection id to each component.
Any Idea? Or any other known solution that can use Vaadin 14 with static connection ids for test needs?
Thanks,
Guy

Hello,

Your approach for V8 has definitely benefits making it more straightforward to create and run performance tests. Unfortunately, while it was relatively easy to override connector id generation in V8, in Flow it is not. The corresponding logic, node id registering happens in com.vaadin.flow.internal.StateTree.register method. Since both UI.internals and UIInternals.stateTree are final fields, it looks there is no easy way override the logic unless you override also UI class.

Instead of overriding this logic, we recommend using regular expression extractors to extract node ids from previous responses. This of course requires some amount of extra work. If you download our Full Stack App starter from https://vaadin.com/start/v14 you can check out how one can use regular expressions to extract those V14 node id on the fly with Gatling. Similar is of course possible with at least JMeter.

Best regards, Johannes

B"H

Thanks Johannes,

as already have the starter project (boot style), I’m not sure what to follow there to check. I saw only unit tests there

Is there is a full how-to to read it will be gr8



By keeping static id, not only code the automation made easier, it also stay stable when changes taking place on page, as the relevant component id stays the same. Anyway those tests cost a lot to create and so I do prefer put effort to do it as simple as can inside the infrastructure

Might make sense Vaadin give some OOTB way for those kind of tests anyway. As stress test is today part of any enterprise deliveries.

Thanks for you answers and help!

Guy

You can find the example Gatling performance test of Full Stack App (Bakery) Starter’s test/scala folder: Barista.scala. See the attached screenshot of how these ids are extracted. Since you already have static ids set, then the form of these regular expressions stays the same making it more straigthforward to proceed. The same is also possible with JMeter, I made simplified JMeter version of that Gatling test: https://gist.github.com/johannest/593309e31e35789f8e5b03bed074f13c

Of course, it is also possible to open a feature request for making it easier to override the id generation: https://github.com/vaadin/flow/issues
18240170.png

B"H

Thanks!

I will look on your code and also will open issue.

Basically our performance team work mostly with LoadRunner, but I guess it is same-same

In addition will explore the way to override Vaadin code (despite I do prefer get a solution from Vaadin), as this will make the performance team life much easier.

our pages use a lot of data, and same components types exist few times, it should be easy for them to reach what they looking for, and also be stable between scenarios.

Guy

B"H

adding issue url for easy tracking in forum

https://github.com/vaadin/flow/issues/8200