Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openwhisk-runtime-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Groundhog
openwhisk-runtime-python
Commits
c037ba38
Commit
c037ba38
authored
8 years ago
by
Ioana Baldini
Browse files
Options
Downloads
Patches
Plain Diff
Improve extract activation id to work for 'wsk activation get' run result
parent
078afc47
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
tests/src/common/Wsk.scala
+42
-3
42 additions, 3 deletions
tests/src/common/Wsk.scala
with
42 additions
and
3 deletions
tests/src/common/Wsk.scala
+
42
−
3
View file @
c037ba38
...
...
@@ -185,18 +185,57 @@ trait DeleteFromCollection extends FullyQualifiedNames {
}
trait
HasActivation
{
/**
* Extracts activation id from invoke (action or trigger) or activation get
*/
def
extractActivationId
(
result
:
RunResult
)
:
Option
[
String
]
=
{
Try
{
// try to interpret the run result as the result of an invoke
extractActivationIdFromInvoke
(
result
)
getOrElse
extractActivationIdFromActivation
(
result
).
get
}
toOption
}
/**
* Extracts activation id from 'wsk activation get' run result
*/
private
def
extractActivationIdFromActivation
(
result
:
RunResult
)
:
Option
[
String
]
=
{
Try
{
// a characteristic string that comes right before the activationId
val
idPrefix
=
"ok: got activation "
val
stdout
=
result
.
stdout
assert
(
stdout
.
contains
(
idPrefix
),
stdout
)
extractActivationId
(
idPrefix
,
stdout
).
get
}
toOption
}
/**
* Extracts activation id from 'wsk action invoke' or 'wsk trigger invoke'
*/
private
def
extractActivationIdFromInvoke
(
result
:
RunResult
)
:
Option
[
String
]
=
{
Try
{
val
stdout
=
result
.
stdout
assert
(
stdout
.
contains
(
"ok: invoked"
)
||
stdout
.
contains
(
"ok: triggered"
),
stdout
)
// a characteristic string that comes right before the activationId
val
idPrefix
=
"with id "
;
val
start
=
result
.
stdout
.
indexOf
(
idPrefix
)
+
idPrefix
.
length
val
idPrefix
=
"with id "
extractActivationId
(
idPrefix
,
stdout
).
get
}
toOption
}
/**
* Extracts activation id preceded by a prefix (idPrefix) from a string (stdout)
*
* @param idPrefix the prefix of the activation id
* @param stdout the string to be used in the extraction
* @return an option containing the id as a string or None if the extraction failed for any reason
*/
private
def
extractActivationId
(
idPrefix
:
String
,
stdout
:
String
)
:
Option
[
String
]
=
{
Try
{
val
start
=
stdout
.
indexOf
(
idPrefix
)
+
idPrefix
.
length
var
end
=
start
assert
(
start
>
0
)
while
(
end
<
stdout
.
length
&&
stdout
.
charAt
(
end
)
!=
'\n'
)
end
=
end
+
1
result
.
stdout
.
substring
(
start
,
end
)
// a uuid
stdout
.
substring
(
start
,
end
)
// a uuid
}
toOption
}
}
...
...
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