-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: e2e agent process #74
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ᕕ(⌐■_■)ᕗ ♪♬
const agentProcess = spawn("pnpm", ["start"], { | ||
env: { | ||
...process.env, | ||
...env, | ||
PROTOCOL_PROVIDER_L1_RPC_URLS: env.PROTOCOL_PROVIDER_L1_RPC_URLS.toString(), | ||
PROTOCOL_PROVIDER_L2_RPC_URLS: env.PROTOCOL_PROVIDER_L2_RPC_URLS.toString(), | ||
BLOCK_NUMBER_RPC_URLS_MAP: blockNumberUrls, | ||
EBO_AGENT_CONFIG_FILE_PATH: path, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😮 never used spawn
but sounds cool, i've always worked with exec
since scripts aren't long lived
curious: spawn is not async, so on return the Agent is supposed to be full-up? isn't any delay we should make?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a super interesting question; I'm no spawn
specialist but it looks like the function returns just right after creating the process, so we have no idea at that moment if the agent is already doing stuff or it's being initialized.
We could listen for its stdout
, waiting for some log (ie "Agent started..." or something like that) to ensure that the agent has started; the good thing about our current E2E approach is that the only way for it to pass it's for the agent to boot up and start generating events. If it does not, it will just time-out and fail.
const generateConfigFile = (path: string, config: AgentConfig) => { | ||
const content = yaml.stringify(config); | ||
|
||
fs.writeFileSync(path, content, "utf-8"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to delete the generated file after test finishes? (i assume tmp path are git-ignored)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!
export const spawnAgent = (params: { config: AgentConfig; env: AgentEnv }) => { | ||
const { config, env } = params; | ||
|
||
const path = "/tmp/config.test.yaml"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about doing
path.join(__dirname, "/tmp/config.test.yaml");
28da2b4
to
d0941a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, lgtm now 🚀
|
||
afterAll(() => { | ||
fs.rmSync(tmpConfigDir, { recursive: true, force: true }); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💎
The base branch was changed.
🤖 Linear
Closes GRT-234
Description
Given that the agent is an "infinite loop" we need to wrap it inside a forked process during each E2E scenario to be able to kill it whenever the test is completed.
Create a
spawnAgent
util function that allows the developer to spawn agents inside processes to be able to terminate them.