Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-3359518
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Issue forks
cloud-3359518
Commits
a1d5c884
Commit
a1d5c884
authored
3 years ago
by
xiaohua guan
Committed by
Yas Naoi
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3202931
by Xiaohua Guan, yas: Add test cases for K8s Schedule (Deployment)
parent
e589ad9e
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
modules/cloud_service_providers/k8s/tests/src/Functional/K8sScheduleTest.php
+69
-13
69 additions, 13 deletions
...ce_providers/k8s/tests/src/Functional/K8sScheduleTest.php
with
69 additions
and
13 deletions
modules/cloud_service_providers/k8s/tests/src/Functional/K8sScheduleTest.php
+
69
−
13
View file @
a1d5c884
...
...
@@ -43,6 +43,13 @@ class K8sScheduleTest extends K8sTestBase {
'edit any k8s pod'
,
'delete any k8s pod'
,
// Deployment.
'list k8s deployment'
,
'add k8s deployment'
,
'view any k8s deployment'
,
'edit any k8s deployment'
,
'delete any k8s deployment'
,
// Launch template.
'add cloud server templates'
,
'list cloud server template'
,
...
...
@@ -58,12 +65,33 @@ class K8sScheduleTest extends K8sTestBase {
}
/**
* Tests CRUD for Schedule of
P
od.
* Tests CRUD for Schedule of
p
od.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public
function
testScheduleForPod
():
void
{
$this
->
runTestForObject
(
'pod'
);
}
/**
* Tests CRUD for Schedule of deployment.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public
function
testScheduleForDeployment
():
void
{
$this
->
runTestForObject
(
'deployment'
);
}
/**
* Runs tests for object.
*
* @param string $object_type
* The object type.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
private
function
runTestForObject
(
$object_type
):
void
{
$object_type_capital
=
ucfirst
(
$object_type
);
$cloud_context
=
$this
->
cloudContext
;
// List Schedule for K8s.
...
...
@@ -71,19 +99,21 @@ class K8sScheduleTest extends K8sTestBase {
$this
->
assertNoErrorMessage
();
// Add a new Schedule.
$add
=
$this
->
createPodTestFormData
(
self
::
K8S_SCHEDULE_REPEAT_COUNT
,
$this
->
namespace
);
$method_name
=
"create${object_type_capital}TestFormData"
;
$add
=
$this
->
$method_name
(
self
::
K8S_SCHEDULE_REPEAT_COUNT
,
$this
->
namespace
);
for
(
$i
=
0
;
$i
<
self
::
K8S_SCHEDULE_REPEAT_COUNT
;
$i
++
)
{
$this
->
reloadMockData
();
$this
->
addPodMockData
(
$add
[
$i
]);
$method_name
=
"add${object_type_capital}MockData"
;
$this
->
$method_name
(
$add
[
$i
]);
$this
->
drupalGet
(
"/clouds/k8s/
$cloud_context
/
pod
/add"
);
$this
->
drupalGet
(
"/clouds/k8s/
$cloud_context
/
$object_type
/add"
);
$this
->
submitForm
(
array_merge
(
$add
[
$i
][
'post_data'
],
[
'enable_time_scheduler'
=>
TRUE
]),
$this
->
t
(
'Save'
)
);
$this
->
assertNoErrorMessage
();
$t_args
=
[
'@type'
=>
'Pod'
,
'%label'
=>
$add
[
$i
][
'name'
]];
$t_args
=
[
'@type'
=>
$object_type_capital
,
'%label'
=>
$add
[
$i
][
'name'
]];
$this
->
assertSession
()
->
pageTextContains
(
strip_tags
(
$this
->
t
(
'The @type %label has been created.'
,
$t_args
)));
// Make sure listing.
...
...
@@ -142,17 +172,39 @@ class K8sScheduleTest extends K8sTestBase {
}
/**
* Tests CRUD for Schedule of template.
* Tests CRUD for Schedule of pod template.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public
function
testScheduleForPodTemplate
():
void
{
$this
->
runTestForTemplate
(
'pod'
);
}
/**
* Tests CRUD for Schedule of deployment template.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public
function
testScheduleForTemplate
():
void
{
public
function
testScheduleForDeploymentTemplate
():
void
{
$this
->
runTestForTemplate
(
'deployment'
);
}
/**
* Runs tests for template.
*
* @param string $object_type
* The object type.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
private
function
runTestForTemplate
(
$object_type
):
void
{
$cloud_context
=
$this
->
cloudContext
;
$data
=
$this
->
createPodTestFormData
(
self
::
K8S_SCHEDULE_REPEAT_COUNT
,
$this
->
namespace
);
$object
=
'pod'
;
$add
=
$this
->
createServerTemplateTestFormData
(
$data
,
'yml'
,
$object
,
[],
self
::
K8S_SCHEDULE_REPEAT_COUNT
);
$object_type_capital
=
ucfirst
(
$object_type
);
$method_name
=
"create${object_type_capital}TestFormData"
;
$data
=
$this
->
$method_name
(
self
::
K8S_SCHEDULE_REPEAT_COUNT
,
$this
->
namespace
);
$add
=
$this
->
createServerTemplateTestFormData
(
$data
,
'yml'
,
$object_type
,
[],
self
::
K8S_SCHEDULE_REPEAT_COUNT
);
for
(
$i
=
0
;
$i
<
self
::
K8S_SCHEDULE_REPEAT_COUNT
;
$i
++
)
{
// field_object is automatically calculated.
...
...
@@ -175,8 +227,12 @@ class K8sScheduleTest extends K8sTestBase {
$this
->
drupalGet
(
"/clouds/design/server_template/
$cloud_context
"
);
// Update the mock data.
$this
->
getMetricsPodMockData
([]);
$this
->
addPodMockData
(
$data
[
$i
]);
if
(
$object_type
===
'pod'
)
{
$this
->
getMetricsPodMockData
([]);
}
$method_name
=
"add${object_type_capital}MockData"
;
$this
->
$method_name
(
$data
[
$i
]);
// Navigate to the launch template, and launch it.
$this
->
clickLink
(
'Launch'
);
...
...
@@ -188,7 +244,7 @@ class K8sScheduleTest extends K8sTestBase {
$this
->
assertNoErrorMessage
();
$t_args
=
[
'@type'
=>
ucfirst
(
$object
),
'@type'
=>
ucfirst
(
$object
_type
),
'%label'
=>
$add
[
$i
][
'name[0][value]'
],
];
$this
->
assertSession
()
->
pageTextContains
(
strip_tags
(
$this
->
t
(
'The @type %label has been launched.'
,
$t_args
)));
...
...
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