Re: Integration test depending of Sling job

2017-12-20 Thread Stefan Egli
Hi Johan,

Could it be that your jobFinised() method returns true since job == null,
which could be the case shortly before/while the job is even being
created? Ie it could be a race condition at the start of the job (and by
adding a 5sec sleep you give it enough time to start + finish).

Cheers,
Stefan

On 19.12.17, 17:34, "Johan Ruttens"  wrote:

>Hi,
>
>I'm working on a (Adobe AEM) integration test, where the test methods
>depend on a job being finished, before the methods can be executed with
>success.
>
>The scenario of the job is a follows:
>1. Copy a page to be used as a test resource (using the PageManager.copy
>method)
>2. Trigger a job (using the JobManager.add method)
>3. The job will alter some properties on the AEM page
>4. Wait until the job has finished
>5. Execute the tests to check if the properties have been changed
>correctly.
>
>
>The problem is that the integration tests sometimes succeed and sometimes
>they do not succeed (i.e. properties are not changed correctly).
>I suspect this is caused by the way we check if the job is finished:
>
>
>@Test
> public void testIfPageIsCorrectTranslated() throws LoginException,
>RepositoryException, InterruptedException, WCMException {
>boolean finished = false;
>while (!finished) {
>Job runningJob = jobManager.getJobById(job.getId());
>finished = jobFinised(runningJob);
>}
>
>
>}
>
>.
>
>private boolean jobFinised(final Job job) {
>return job == null || job.getJobState().equals(Job.JobState.SUCCEEDED)
>|| job.getJobState().equals(Job.JobState.ERROR) ||
>job.getJobState().equals(Job.JobState.STOPPED);
>}
>
>
>When I add a Thread.sleep(5000) after the while loop, all the tests
>succeed
>all of the time.
>
>
>Thanks for the help.




Re: Maven plugin to set property on a resource

2017-12-20 Thread Jason E Bailey
I was thinking more along the lines of this example that I copied and
pasted from the internets. I could see where it would be useful to have
the ability to do a simple web request and then potentially handle an
error out of it.

  org.codehaus.mojo
  exec-maven-plugin
  1.2
  

  drop DB => db_name
  pre-integration-test
  
exec
  
  
curl

  -s
  -S
  -X
  DELETE
  http://${db.server}:${db.port}/db_name

  

  


--
Jason



On Tue, Dec 19, 2017, at 5:39 PM, Roy Teeuwen wrote:
> Hey Jason, 
> 
> Yup, thats what I got to at this point, maybe there was a cleaner way,
> but I guess this will do :)> 
> Just for ppl for future references, this is my final result (pretty
> long, thats why I was looking for something less bulky, but could
> always make a separate plugin if necessary> 
> <*plugin*>
> 
> 
> 
> 
> <*groupId*>org.codehaus.groovy.maven
> 
> 
> 
> 
> <*artifactId*>gmaven-plugin
> 
> 
> 
> 
> <*executions*>
> 
> 
> 
> 
> <*execution*>
> 
> 
> 
> 
> <*id*>disable-dam-workflows
> 
> 
> 
> 
> <*phase*>pre-integration-test
> 
> 
> 
> 
> <*goals*>
> 
> 
> 
> 
> <*goal*>execute
> 
> 
> 
> 
> 
> 
> 
> 
> 
> <*configuration*>
> 
> 
> 
> 
> <*source*>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> <*execution*>
> 
> 
> 
> 
> <*id*>enable-dam-workflows
> 
> 
> 
> 
> <*phase*>post-integration-test
> 
> 
> 
> 
> <*goals*>
> 
> 
> 
> 
> <*goal*>execute
> 
> 
> 
> 
> 
> 
> 
> 
> 
> <*configuration*>
> 
> 
> 
> 
> <*source*>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Greets,
> Roy
> 
>> On 19 Dec 2017, at 23:32, Jason E Bailey
>>  wrote:>> 
>> Maybe something like maven exec or maven antrun to perform a curl
>> command?>> 
>> --
>> Jason
>> 
>> On Tue, Dec 19, 2017, at 1:04 PM, Roy Teeuwen wrote:
>>> Hey all,
>>> 
>>> I am searching for the fastest way to set and delete a property on a>>> 
>>> resource of a specific path. I could use the gmaven-plugin and
>>> write a>>> groovy script to do this, but maybe there is already someone 
>>> with a>>> better plugin for this and I don't have to write an ugly script
>>> for it>>> in my pom.xml.
>>> 
>>> Just for the people who want to know what I want to achieve: I am 
>>> installing my content package with test content(filevault xmls) and>>> 
>>> images inside, but before I want to install it, I would like to
>>> disable>>> a workflow (more specifically the update dam asset workflow)
>>> because the>>> renditions are already in the test-content and it slows down 
>>> the
>>> system>>> because of the heavy workflow/jobs triggering.
>>> 
>>> Greets,
>>> Roy
>>> Email had 1 attachment:
>>> + signature.asc
>>>  1k (application/pgp-signature)
> Email had 1 attachment:


>  * signature.asc 1k (application/pgp-signature)


Re: Maven plugin to set property on a resource

2017-12-20 Thread Justin Edelson
FWIW, it is possible to externalize that script into a file and then
reference it as the source parameter. It's obviously a judgement call as to
whether you put the script inline or in an external files, but the below
would be enough lines of code for me to want to stick it in an external
file :)

Justin

On Tue, Dec 19, 2017 at 5:40 PM Roy Teeuwen  wrote:

> Hey Jason,
>
> Yup, thats what I got to at this point, maybe there was a cleaner way, but
> I guess this will do :)
>
> Just for ppl for future references, this is my final result (pretty long,
> thats why I was looking for something less bulky, but could always make a
> separate plugin if necessary
>
> 
> org.codehaus.groovy.maven
> gmaven-plugin
> 
> 
> disable-dam-workflows
> pre-integration-test
> 
> execute
> 
> 
> 
> 
> 
> 
> enable-dam-workflows
> post-integration-test
> 
> execute
> 
> 
> 
> 
> 
> 
>
> Greets,
> Roy
>
> On 19 Dec 2017, at 23:32, Jason E Bailey  wrote:
>
> Maybe something like maven exec or maven antrun to perform a curl command?
>
> --
> Jason
>
> On Tue, Dec 19, 2017, at 1:04 PM, Roy Teeuwen wrote:
>
> Hey all,
>
> I am searching for the fastest way to set and delete a property on a
> resource of a specific path. I could use the gmaven-plugin and write a
> groovy script to do this, but maybe there is already someone with a
> better plugin for this and I don't have to write an ugly script for it
> in my pom.xml.
>
> Just for the people who want to know what I want to achieve: I am
> installing my content package with test content(filevault xmls) and
> images inside, but before I want to install it, I would like to disable
> a workflow (more specifically the update dam asset workflow) because the
> renditions are already in the test-content and it slows down the system
> because of the heavy workflow/jobs triggering.
>
> Greets,
> Roy
> Email had 1 attachment:
> + signature.asc
>  1k (application/pgp-signature)
>
>
>


Re: Maven plugin to set property on a resource

2017-12-20 Thread Roy Teeuwen
Ah cool, good to know, thanks Justin! That was indeed my problem with the thing 
that I wrote, I hate to have something this bloated in my pom.xml, but I find 
it too small to make an actual maven plugin for it

Greets,
Roy

> On 20 Dec 2017, at 14:47, Justin Edelson  wrote:
> 
> FWIW, it is possible to externalize that script into a file and then
> reference it as the source parameter. It's obviously a judgement call as to
> whether you put the script inline or in an external files, but the below
> would be enough lines of code for me to want to stick it in an external
> file :)
> 
> Justin
> 
> On Tue, Dec 19, 2017 at 5:40 PM Roy Teeuwen  wrote:
> 
>> Hey Jason,
>> 
>> Yup, thats what I got to at this point, maybe there was a cleaner way, but
>> I guess this will do :)
>> 
>> Just for ppl for future references, this is my final result (pretty long,
>> thats why I was looking for something less bulky, but could always make a
>> separate plugin if necessary
>> 
>> 
>>org.codehaus.groovy.maven
>>gmaven-plugin
>>
>>
>>disable-dam-workflows
>>pre-integration-test
>>
>>execute
>>
>>
>>
>>
>>
>>
>>enable-dam-workflows
>>post-integration-test
>>
>>execute
>>
>>
>>
>>
>>
>>
>> 
>> Greets,
>> Roy
>> 
>> On 19 Dec 2017, at 23:32, Jason E Bailey  wrote:
>> 
>> Maybe something like maven exec or maven antrun to perform a curl command?
>> 
>> --
>> Jason
>> 
>> On Tue, Dec 19, 2017, at 1:04 PM, Roy Teeuwen wrote:
>> 
>> Hey all,
>> 
>> I am searching for the fastest way to set and delete a property on a
>> resource of a specific path. I could use the gmaven-plugin and write a
>> groovy script to do this, but maybe there is already someone with a
>> better plugin for this and I don't have to write an ugly script for it
>> in my pom.xml.
>> 
>> Just for the people who want to know what I want to achieve: I am
>> installing my content package with test content(filevault xmls) and
>> images inside, but before I want to install it, I would like to disable
>> a workflow (more specifically the update dam asset workflow) because the
>> renditions are already in the test-content and it slows down the system
>> because of the heavy workflow/jobs triggering.
>> 
>> Greets,
>> Roy
>> Email had 1 attachment:
>> + signature.asc
>> 1k (application/pgp-signature)
>> 
>> 
>> 



signature.asc
Description: Message signed with OpenPGP


Re: Integration test depending of Sling job

2017-12-20 Thread Johan Ruttens
Hi Stefan,

Thank you for your response.
I think the null check on the job is indeed the problem.

I added this check, because it seems that when after the job is finished
(handled) it also becomes null, and I have no longer the possibility to
retrieve the jobState from this object.

So in the current code I cannot use the null check to determine if the job
has finished (as it might not be created yet), but if the job is already
finished and has become null I would need the null check.

Basically I'm searching for a better way to determine when the job is
finished.


Thanks

Johan

2017-12-20 11:34 GMT+01:00 Stefan Egli :

> Hi Johan,
>
> Could it be that your jobFinised() method returns true since job == null,
> which could be the case shortly before/while the job is even being
> created? Ie it could be a race condition at the start of the job (and by
> adding a 5sec sleep you give it enough time to start + finish).
>
> Cheers,
> Stefan
>
> On 19.12.17, 17:34, "Johan Ruttens"  wrote:
>
> >Hi,
> >
> >I'm working on a (Adobe AEM) integration test, where the test methods
> >depend on a job being finished, before the methods can be executed with
> >success.
> >
> >The scenario of the job is a follows:
> >1. Copy a page to be used as a test resource (using the PageManager.copy
> >method)
> >2. Trigger a job (using the JobManager.add method)
> >3. The job will alter some properties on the AEM page
> >4. Wait until the job has finished
> >5. Execute the tests to check if the properties have been changed
> >correctly.
> >
> >
> >The problem is that the integration tests sometimes succeed and sometimes
> >they do not succeed (i.e. properties are not changed correctly).
> >I suspect this is caused by the way we check if the job is finished:
> >
> >
> >@Test
> > public void testIfPageIsCorrectTranslated() throws LoginException,
> >RepositoryException, InterruptedException, WCMException {
> >boolean finished = false;
> >while (!finished) {
> >Job runningJob = jobManager.getJobById(job.getId());
> >finished = jobFinised(runningJob);
> >}
> >
> >
> >}
> >
> >.
> >
> >private boolean jobFinised(final Job job) {
> >return job == null || job.getJobState().equals(Job.
> JobState.SUCCEEDED)
> >|| job.getJobState().equals(Job.JobState.ERROR) ||
> >job.getJobState().equals(Job.JobState.STOPPED);
> >}
> >
> >
> >When I add a Thread.sleep(5000) after the while loop, all the tests
> >succeed
> >all of the time.
> >
> >
> >Thanks for the help.
>
>
>


Re: Integration test depending of Sling job

2017-12-20 Thread Bertrand Delacretaz
Hi,

On Wed, Dec 20, 2017 at 3:16 PM, Johan Ruttens  wrote:
>... Basically I'm searching for a better way to determine when the job is
> finished

I don't remember the details off the top of my head but I suppose OSGi
events are sent to indicate the job's progress - you can check at
/system/console/events and if you see useful events, using those
should be a better way to find out.

-Bertrand


Tracking of use of sling vanity urls

2017-12-20 Thread Roy Teeuwen
Hey all,

We have a use case that we would like to track in our analytics if a vanity url 
is used. A user comes in on the site with https://www.mysite.com/my-vanity-url 
 and gets rewritten to 
https://www.mysite.com/my/real/page.html 

How we think we could maybe solve this is by actually rewriting the url to 
https://www.mysite.com/my/real/page.html?s=/my-vanity-url 
 so that analytics 
can catch this. Is there any possibility so far to alter the behaviour of how 
the vanity url's get handled?

I'm asking here first because maybe you guys can already say, don't count on 
ever getting that to work without an entire rebuild of the vanity system :)...

Greets,
Roy


signature.asc
Description: Message signed with OpenPGP