forked from bigsea-ufcg/bigsea-manager
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating documentation; Fixing test bugs
- Loading branch information
1 parent
8c62cb5
commit c909447
Showing
16 changed files
with
683 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"username": "user", | ||
"password": "psswrd", | ||
"cmd": ["python", "app.py"], | ||
"img": "ip:port/kubejobsapp:demo", | ||
"init_size": 1, | ||
"redis_workload": "http://test.test", | ||
"monitor_plugin": "kubejobs", | ||
"enable_visualizer": false, | ||
"monitor_info": { | ||
"expected_time": 500 | ||
}, | ||
"visualizer_plugin": "k8s-grafana", | ||
"visualizer_info": { | ||
"datasource_type": "influxdb" | ||
}, | ||
"env_vars": { | ||
"S_USERNAME": "user", | ||
"PASSWORD":"psswrd", | ||
"AUTH_URL":"https://auth.com", | ||
"PROJECT_ID":"00001", | ||
"PROJECT_NAME": "project", | ||
"PROJECT_DOMAIN_NAME":"domain", | ||
"USER_DOMAIN_NAME":"domain", | ||
"CONTAINER_NAME":"container" | ||
}, | ||
"enable_visualizer":true, | ||
"visualizer_plugin":"k8s-grafana", | ||
"visualizer_info":{ | ||
"datasource_type":"influxdb" | ||
}, | ||
"config_id": 1, | ||
"enable_auth": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# Copyright (c) 2017 UFCG-LSD. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
This entire module has the object of simulate a | ||
Kubernetes (k8s) Object with tests purposes | ||
""" | ||
|
||
""" | ||
Class that represents a mock of the Job object | ||
""" | ||
class Job(): | ||
|
||
""" Constructor of the mock of a Job object | ||
Returns: | ||
Job: The simulation of a Job object | ||
""" | ||
def __init__(self, active): | ||
self.status = Status(active) | ||
|
||
""" | ||
Class that represents a mock of the Status object | ||
""" | ||
class Status(): | ||
|
||
""" Constructor of the mock of a Status object | ||
Args: | ||
active (string): Representing status of the object. | ||
Returns: | ||
Status: The simulation of a Status object | ||
""" | ||
def __init__(self, active): | ||
self.active = active | ||
|
||
""" | ||
Class that represents a mock of the k8s object | ||
""" | ||
class MockKube(): | ||
|
||
""" Constructor of the mock of a k8s object | ||
Args: | ||
app_id (string): Representing id of the application. | ||
replicas (int): Representing number of replicas of the application | ||
namespace (string): Representing the namespace of the application | ||
Returns: | ||
MockKube: A mock of a k8s object | ||
""" | ||
def __init__(self, app_id, replicas=1, namespace="default"): | ||
self.jobs = {namespace: {app_id: replicas}} | ||
|
||
""" Function that simulates the read of a namespaced job | ||
Args: | ||
name (string): Representing name of the job. | ||
namespace (string): Representing the namespace of the job | ||
Returns: | ||
Job: The simulation of the Job object searched | ||
""" | ||
def read_namespaced_job(self, name, namespace="default"): | ||
out = Job(self.jobs[namespace][name]) | ||
return out | ||
|
||
|
||
""" Function that simulates the creation of a job | ||
Args: | ||
app_id (string): Representing id of the application | ||
cmd (string): Representing the command executed | ||
img (string): Representing the image of the application | ||
init_size (string): Representing the size of the application | ||
env_vars (string): Representing the environmental variables of | ||
the application | ||
config_id (string): Representing the config id of the application | ||
Returns: | ||
None | ||
""" | ||
def create_job(self, app_id, cmd, img, init_size, | ||
env_vars, config_id=""): | ||
pass | ||
|
||
""" Function that simulates the provision of death of | ||
the redis | ||
Args: | ||
app_id (string): Representing id of the application | ||
Returns: | ||
tuple: Representing the redis_ip and node_port | ||
""" | ||
def provision_redis_or_die(self, app_id): | ||
return (None, None) | ||
|
||
""" Function that gets the status of completion of | ||
a job. | ||
Args: | ||
app_id (string): Representing id of the application | ||
Returns: | ||
bool: Representing the status of completion | ||
of the job | ||
""" | ||
def completed(self, app_id): | ||
return True | ||
|
||
""" Function that simulates a deletion of the | ||
redis resources | ||
Args: | ||
app_id (string): Representing id of the application | ||
Returns: | ||
None | ||
""" | ||
def delete_redis_resources(self, app_id): | ||
pass | ||
|
||
""" Function that simulates a termination | ||
of the job. | ||
Args: | ||
app_id (string): Representing id of the application | ||
Returns: | ||
None | ||
""" | ||
def terminate_job(self, app_id): | ||
self.jobs["default"].pop(app_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (c) 2017 UFCG-LSD. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
Class that represents a mock of the redis object | ||
""" | ||
class MockRedis(): | ||
|
||
""" Constructor of the mock of a redis object | ||
Returns: | ||
MockRedis: The simulation of a redis object | ||
""" | ||
def __init__(self): | ||
self.map = {} | ||
|
||
""" Function the simulates the push of a job in the | ||
redis queue | ||
Args: | ||
metric_queue (string): Representing the metric queue | ||
metric (Object): Representing the metric to be pushed in the | ||
queue. | ||
Returns: | ||
None | ||
""" | ||
def rpush(self, metric_queue, metric): | ||
if self.map.get(metric_queue) == None: | ||
self.map[metric_queue] = [] | ||
|
||
self.map[metric_queue].append(metric) | ||
|
||
""" Function the simulates the pop of a job from the | ||
redis queue | ||
Args: | ||
metric_queue (string): Representing the metric queue | ||
Returns: | ||
Object: Representing the metric pop from the queue | ||
""" | ||
def rpop(self, metric_queue): | ||
try: | ||
return self.map.get(metric_queue).pop(0) | ||
except Exception as e: | ||
print e | ||
|
||
""" Function the simulates the deletion of a | ||
redis queue | ||
Args: | ||
queue_name (string): Representing the name of the queue to | ||
be deleted. | ||
Returns: | ||
None | ||
""" | ||
def delete(self, queue_name): | ||
self.map.pop(queue_name) | ||
|
Empty file.
Empty file.
Oops, something went wrong.