Open renzedj opened 7 months ago
Thanks for raising the issue @renzedj, The way push command works is by
journey
invocations and then getting the location information of these filesSince the factory contains the invocation of the journey()
inside the Class definition itself, the journey-factory.journey.ts
is not useful here since its not doing anything other than calling the invoker itself where the actual journey is defined. The other issue is, even though the bundle contains the all the necessary information to run the required journey, The reason why its failing is because the filename is journey-factory.ts
, Synthetics runner by default looks for files that are matching /*.journey.(ts|js)$/
format. Since the filename is not matched, the run yields no Steps to run
.
We follow similar factory patterns, but try to do one of these things
helper.journey.ts
and let the caller invoke different journeys based on individual configuration (be it journey name, environments, etc).
import {createJourney} from "./helper";
import {journey} from "@elastic/synthetics";
journey("name", async() => { createJourney(); })
Let us know if you have more questions or feedback. Thanks.
Thanks for raising the issue @renzedj, The way push command works is by
- Traversing for all the
journey
invocations and then getting the location information of these files- Bundling them and pushing them over to the Kibana backend
This is what I suspected, when I compared it with the way that the advanced-example.journey.ts
handles the import. Can you please clarify this in the documentation? Knowing this, I get this from documentation. But without knowing it in advance, it reads like it starts from *.journey.ts
and traverses from there.
Since the factory contains the invocation of the
journey()
inside the Class definition itself, thejourney-factory.journey.ts
is not useful here since its not doing anything other than calling the invoker itself where the actual journey is defined. The other issue is, even though the bundle contains the all the necessary information to run the required journey, The reason why its failing is because the filename isjourney-factory.ts
, Synthetics runner by default looks for files that are matching/*.journey.(ts|js)$/
format. Since the filename is not matched, the run yields noSteps to run
.
While I can see why the decision was made to go with this for bundling, IMO this limits the utility of the factory pattern, which would otherwise be able to return a complete journey to be invoked, like in the example I provided. If the synthetics agent looks for the *.journey.(js|ts)
to execute, then the bundling SHOULD do the same. Seems to me that this would also make it easier to scan for journeys, as you don't have to open each file to look for the journey
definition. Doing this would also allow the use of feature flags to more easily promote tests through regions.
While I realize that this would likely be lower in priority, I would like to request this as a change. This SHOULD NOT be a breaking change, as anything written assuming the current bundling method would still work, since it's defining the journey in the journey file.
We follow similar factory patterns, but try to do one of these things
- Either move the helper function inside
helper.journey.ts
and let the caller invoke different journeys based on individual configuration (be it journey name, environments, etc).- Keep the journey invocation in the corresponding file and use a helper API for the individual steps.
import {createJourney} from "./helper"; import {journey} from "@elastic/synthetics"; journey("name", async() => { createJourney(); })
Let us know if you have more questions or feedback. Thanks.
The first is what I'm doing now and it's less than optimum. The second is the next thing I was going to try on this. Thanks for the confirmation. Thx also for the quick response, even if it's not what I wanted to hear. 😄
I initially thought that this was the same issue as Issue #693, but I did a deeper dive after the response I got on that issue and think that while it may be related, it's not the same issue.
I am using a factory pattern to generate identical tests which run against multiple endpoints. When I separate the factory module from the journey file, only the factory module is bundled by NPM and pushed to the cluster.
This has been validated with
@elastic/synthetics-1.7.2
.Steps to reproduce
@elastic/synthetics
project.npx @elastic/synthetics .
Results
Everything runs as expected when running locally from the command line with
npx @elastic/synthetics .
.When I push it to my Elastic Cluster, it generates the following error:
When I look at the correct folder on the Agent, I see the following:
When I examine the contents of
journey-factory.ts
, it corresponds to the module, I'm not able to find the actual journey file.If I define the factory class and instantiate it in the same file, everything runs as expected.
Originally posted by @renzedj in https://github.com/elastic/synthetics/issues/693#issuecomment-2007373096