Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Create Llama
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Create Llama
Commits
9f739b98
Unverified
Commit
9f739b98
authored
8 months ago
by
Marcus Schiesser
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: cleaned e2e runner (#215)
parent
c06ec4f1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
e2e/utils.ts
+52
-59
52 additions, 59 deletions
e2e/utils.ts
with
52 additions
and
59 deletions
e2e/utils.ts
+
52
−
59
View file @
9f739b98
...
@@ -18,48 +18,6 @@ export type CreateLlamaResult = {
...
@@ -18,48 +18,6 @@ export type CreateLlamaResult = {
appProcess
:
ChildProcess
;
appProcess
:
ChildProcess
;
};
};
// eslint-disable-next-line max-params
export
async
function
checkAppHasStarted
(
frontend
:
boolean
,
framework
:
TemplateFramework
,
port
:
number
,
externalPort
:
number
,
timeout
:
number
,
)
{
if
(
frontend
)
{
await
Promise
.
all
([
waitPort
({
host
:
"
localhost
"
,
port
:
port
,
timeout
,
}),
waitPort
({
host
:
"
localhost
"
,
port
:
externalPort
,
timeout
,
}),
]).
catch
((
err
)
=>
{
console
.
error
(
err
);
throw
err
;
});
}
else
{
let
wPort
:
number
;
if
(
framework
===
"
nextjs
"
)
{
wPort
=
port
;
}
else
{
wPort
=
externalPort
;
}
await
waitPort
({
host
:
"
localhost
"
,
port
:
wPort
,
timeout
,
}).
catch
((
err
)
=>
{
console
.
error
(
err
);
throw
err
;
});
}
}
// eslint-disable-next-line max-params
// eslint-disable-next-line max-params
export
async
function
runCreateLlama
(
export
async
function
runCreateLlama
(
cwd
:
string
,
cwd
:
string
,
...
@@ -142,25 +100,10 @@ export async function runCreateLlama(
...
@@ -142,25 +100,10 @@ export async function runCreateLlama(
templateFramework
,
templateFramework
,
port
,
port
,
externalPort
,
externalPort
,
1000
*
60
*
5
,
);
);
}
else
{
}
else
{
// wait create-llama to exit
// wait 10 seconds for create-llama to exit
// we don't test install dependencies for now, so just set timeout for 10 seconds
await
waitForProcess
(
appProcess
,
1000
*
10
);
await
new
Promise
((
resolve
,
reject
)
=>
{
const
timeout
=
setTimeout
(()
=>
{
reject
(
new
Error
(
"
create-llama timeout error
"
));
},
1000
*
10
);
appProcess
.
on
(
"
exit
"
,
(
code
)
=>
{
if
(
code
!==
0
&&
code
!==
null
)
{
clearTimeout
(
timeout
);
reject
(
new
Error
(
"
create-llama command was failed!
"
));
}
else
{
clearTimeout
(
timeout
);
resolve
(
undefined
);
}
});
});
}
}
return
{
return
{
...
@@ -174,3 +117,53 @@ export async function createTestDir() {
...
@@ -174,3 +117,53 @@ export async function createTestDir() {
await
mkdir
(
cwd
,
{
recursive
:
true
});
await
mkdir
(
cwd
,
{
recursive
:
true
});
return
cwd
;
return
cwd
;
}
}
// eslint-disable-next-line max-params
async
function
checkAppHasStarted
(
frontend
:
boolean
,
framework
:
TemplateFramework
,
port
:
number
,
externalPort
:
number
,
)
{
const
portsToWait
=
frontend
?
[
port
,
externalPort
]
:
[
framework
===
"
nextjs
"
?
port
:
externalPort
];
await
waitPorts
(
portsToWait
);
}
async
function
waitPorts
(
ports
:
number
[]):
Promise
<
void
>
{
const
waitForPort
=
async
(
port
:
number
):
Promise
<
void
>
=>
{
await
waitPort
({
host
:
"
localhost
"
,
port
:
port
,
// wait max. 5 mins for start up of app
timeout
:
1000
*
60
*
5
,
});
};
try
{
await
Promise
.
all
(
ports
.
map
(
waitForPort
));
}
catch
(
err
)
{
console
.
error
(
err
);
throw
err
;
}
}
async
function
waitForProcess
(
process
:
ChildProcess
,
timeoutMs
:
number
,
):
Promise
<
void
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
timeout
=
setTimeout
(()
=>
{
reject
(
new
Error
(
"
Process timeout error
"
));
},
timeoutMs
);
process
.
on
(
"
exit
"
,
(
code
)
=>
{
clearTimeout
(
timeout
);
if
(
code
!==
0
&&
code
!==
null
)
{
reject
(
new
Error
(
"
Process exited with non-zero code
"
));
}
else
{
resolve
();
}
});
});
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment