meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sap_hybris_commerce:development_process:systemsetup_annotation_when_methods_run [2020/04/10 11:35] – [SystemSetup Annotation: When are the methods run?] Antonio Robirosasap_hybris_commerce:development_process:systemsetup_annotation_when_methods_run [2020/04/10 14:03] (current) – Document the hybris classes Antonio Robirosa
Line 3: Line 3:
 The SystemSetup annotation is used to run import data, synchronize catalogues, migrate CMS components and execute Java code during **every** project or essential data creation step. The SystemSetup annotation is used to run import data, synchronize catalogues, migrate CMS components and execute Java code during **every** project or essential data creation step.
  
-**In past versions the essential and project data steps weren't run during the initialization of the junit tenant.** This prevented the import of test data for the integration tests if you weren't using the [[https://github.com/arobirosa/areco-deployment-script-manager|Areco deployment script manager]] as patch system. To get an updated picture of the current situation, I ran a test on the latest SAP hybris versions and here are the results:+**In all hybris version up to 1905 the essential and project data steps aren't run during the initialization of the junit tenant.** This prevents the import of common test data for complex integration tests if you weren't using the [[https://github.com/arobirosa/areco-deployment-script-manager|Areco deployment script manager]] as patch system. To get an updated picture of the current situation, I ran a test on the latest SAP hybris version 1905 and here are the results are the same as with old versions:
  
 ^SystemSetup.Process^INIT^^^UPDATE^^^ALL^^^.^ ^SystemSetup.Process^INIT^^^UPDATE^^^ALL^^^.^
 ^SystemSetup.Type^ESSENTIAL^PROJECT^ALL^ESSENTIAL^PROJECT^ALL^ESSENTIAL^PROJECT^ALL^What Hybris impexes are imported?^ ^SystemSetup.Type^ESSENTIAL^PROJECT^ALL^ESSENTIAL^PROJECT^ALL^ESSENTIAL^PROJECT^ALL^What Hybris impexes are imported?^
-^ant initialize -Dtenant=master|Called once with extension arecosystemsetuptest, process INIT and type ESSENTIAL|Called once with extension arecosystemsetuptest, process INIT and type PROJECT|Called twice with extension arecosystemsetuptest, process INIT and type ESSENTIAL \\ and with extension arecosystemsetuptest, process INIT and type PROJECT|No call|||Called once with extension arecosystemsetuptest, process INIT and type ESSENTIAL|Called once with extension arecosystemsetuptest, process INIT and type PROJECT|Called twice with extension arecosystemsetuptest, process INIT and type ESSENTIAL \\ and with extension arecosystemsetuptest, process INIT and type PROJECT|Project and essential scripts| +^ant initialize -Dtenant=master|Called once with process INIT and type ESSENTIAL|Called once with process INIT and type PROJECT|Called twice with process INIT and type ESSENTIAL \\ and with process INIT and type PROJECT|No call|||Called once with process INIT and type ESSENTIAL|Called once with process INIT and type PROJECT|Called twice with process INIT and type ESSENTIAL \\ and with process INIT and type PROJECT|Project and essential scripts| 
-^ant initialize -Dtenant=junit|No call|||||||||:!: None| +^ant initialize -Dtenant=junit|:!: No call|||||||||:!: None| 
-^ant yunitinit|No call|||||||||:!: None| +^ant yunitinit|:!: No call|||||||||:!: None| 
-^ant updatesystem -Dtenant=master((with a JSON configuration to run the project data))|No call|||Called once with extension arecosystemsetuptest, process UPDATE and type ESSENTIAL|Called once with extension arecosystemsetuptest, process UPDATE and type PROJECT|Called twice with extension arecosystemsetuptest, process UPDATE and type ESSENTIAL and with extension arecosystemsetuptest, process UPDATE and type PROJECT|Called once with extension arecosystemsetuptest, process UPDATE and type ESSENTIAL|Called once with extension arecosystemsetuptest, process UPDATE and type PROJECT|Called twice with extension arecosystemsetuptest, process INIT and type ESSENTIAL and with extension arecosystemsetuptest, process INIT and type PROJECT|Project and essential scripts| +^ant updatesystem -Dtenant=master((with a JSON configuration to run the project data))|No call|||Called once with process UPDATE and type ESSENTIAL|Called once with process UPDATE and type PROJECT|Called twice with  process UPDATE and type ESSENTIAL and with process UPDATE and type PROJECT|Called once with process UPDATE and type ESSENTIAL|Called once with process UPDATE and type PROJECT|Called twice with process INIT and type ESSENTIAL and with process INIT and type PROJECT|Project and essential scripts| 
-^ant updatesystem -Dtenant=junit((with a JSON configuration to run the project data))|1|2|3|4|5|6|7|8|9+^ant updatesystem -Dtenant=junit((with a JSON configuration to run the project data))|:!: No call|||||||||:!: None
-^On HAC, initialize of the master tenant|1|2|3|4|5|6|7|8|9+^ant yunitupdate|:!: No call|||||||||:!: None
-^On HACinitialize of the master yunit|1|2|3|4|5|6|7|8|9| + 
-^On HAC, update running system of the master tenant|1|2|3|4|5|6|7|8|9| +When @SystemSetup(extension = ArecosystemsetuptestConstants.EXTENSIONNAME)the field hybrisContext.getExtensionName() always contains the name of the current extension. \\ 
-^On HAC, update running system of the master yunit|1|2|3|4|5|6|7|8|9|+When @SystemSetup(extension = "ALL_EXTENSIONS") is used, the methods annotated with @SystemSetup are called as above once or twice **per each hybris and custom extension**. Each time the field hybrisContext.getExtensionName() contains the name of a different extension. 
 + 
 +<WRAP center round important 60%> 
 +Because the majority of the SAP hybris projects use Jenkins and **ant targets** to deploy, update system and initialization using HAC wasn't tested. 
 +</WRAP> 
 +===== Cause of this behaviour ===== 
 + 
 +The method de.hybris.ant.taskdefs.InitPlatformAntPerformableImpl#performImpl checks if the current tenant is named **junit** and runs an initialization without essential and project data. This also happens with the update system. Please see the code of UpdatePlatformAntPerformableImpl.
  
 ===== Test description ===== ===== Test description =====
-I created a new extension based on the templa yempty and added the property "initialpassword.admin=nimdato the local.properies. Then I create a class for the test and annotated at class level with:+I created a new extension based on the templa yempty and added the property **initialpassword.admin=nimda** to the local.properies. Then I created {{ :sap_hybris_commerce:development_process:systemsetupannotationcallstest.java | class for the test}} and annotated at class level with:
 <code java> <code java>
-@SystemSetup(extension = "ALL_EXTENSIONS")+@SystemSetup(extension = ArecosystemsetuptestConstants.EXTENSIONNAME)
 public class SystemSetupAnnotationCallsTest { public class SystemSetupAnnotationCallsTest {
 </code> </code>
Line 30: Line 37:
 } }
 </code> </code>
-<WRAP center round important 100%>+<WRAP center round important 60%>
 To make hybris call the methods, I had to create a bean definition in the spring application context. Autowiring without the XML bean definition wasn't working. To make hybris call the methods, I had to create a bean definition in the spring application context. Autowiring without the XML bean definition wasn't working.
 </WRAP> </WRAP>
 +<code xml>
 +    <bean id="systemSetupAnnotationCallsTest" class="org.areco.ecommerce.tests.systemsetup.setup.SystemSetupAnnotationCallsTest" />
 +</code>
  
-I ran all ant commands and process on HAC and I analysed the log afterwards: + 
-<code>+I created a JSON configuration for the update running system which runs the create project data step: {{ :sap_hybris_commerce:development_process:updatesystemconfigfile.json | updatesystemconfigfile.json}} \\ 
 +I ran the following commands and I analysed the log afterwards: 
 +<code bash> 
 +rm -rf hybris/data/ 
 +ant clean all
 ant initialize -Dtenant=master | tee initializeMaster.log | grep SystemSetupAnnotationCallsTest ant initialize -Dtenant=master | tee initializeMaster.log | grep SystemSetupAnnotationCallsTest
 +ant initialize -Dtenant=junit | tee initializeJunit.log | grep SystemSetupAnnotationCallsTest
 +ant yunitinit | tee yunitinit.log | grep SystemSetupAnnotationCallsTest
 +ant updatesystem -Dtenant=master -DconfigFile=/home/arobirosa/no_backup/areco/arecodeploymentscriptsmanager-1905/hybris/bin/custom/arecosystemsetuptest/resources/updateSystemConfigFile.json | tee updateMaster.log | grep SystemSetupAnnotationCallsTest
 +ant updatesystem -Dtenant=yunit -DconfigFile=/home/arobirosa/no_backup/areco/arecodeploymentscriptsmanager-1905/hybris/bin/custom/arecosystemsetuptest/resources/updateSystemConfigFile.json | tee updateJunit.log | grep SystemSetupAnnotationCallsTest
 +ant yunitupdate -DconfigFile=/home/arobirosa/no_backup/areco/arecodeploymentscriptsmanager-1905/hybris/bin/custom/arecosystemsetuptest/resources/updateSystemConfigFile.json | tee yunitUpdate.log | grep SystemSetupAnnotationCallsTest
 </code> </code>
 +
 +Source code: {{ :sap_hybris_commerce:development_process:systemsetupannotationcallstest.java | SystemSetupAnnotationCallsTest.java}} {{ :sap_hybris_commerce:development_process:updatesystemconfigfile.json | updatesystemconfigfile.json}}
  
 -- Based on SAP hybris 1905 -- Based on SAP hybris 1905