Skip to content
This repository was archived by the owner on Jan 6, 2018. It is now read-only.

Commit 988c470

Browse files
Merge pull request #14 from deepeshmittal/master
Backup/Restore scripts added - Kill test enable only for admin or test owner - bug fixes - fix for test abort while in waiting queue
2 parents 3fa2e37 + 45dc638 commit 988c470

File tree

8 files changed

+145
-16
lines changed

8 files changed

+145
-16
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
source config.sh
4+
5+
if [ -z $db_name ] || [ -z $db_user ] || [ -z $db_password ] || [ -z $db_host ] || [ -z $db_root_pass ] || [ -z $daytona_install_dir ] || [ -z $daytona_data_dir ] || [ -z $ui_admin_pass ] || [ -z $email_user ] || [ -z $email_domain ] || [ -z $smtp_server ] || [ -z $smtp_port ]; then
6+
echo 'one or more variables are undefined in config.sh'
7+
echo 'Please configure config.sh'
8+
echo 'For details that are unknown, enter some dummy values'
9+
exit 1
10+
fi
11+
12+
daytona_db_backup=$HOME/daytona_db_backup.sql
13+
daytona_data_backup=$HOME/daytona_data_backup.tar.gz
14+
15+
sudo rm -rf $daytona_db_backup $daytona_data_backup
16+
17+
mysqldump -u ${db_user} -p${db_password} ${db_name} > $daytona_db_backup
18+
19+
cd $daytona_data_dir
20+
sudo tar -cvf $daytona_data_backup .
21+
22+
cd -
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
source config.sh
4+
5+
if [ -z $db_name ] || [ -z $db_user ] || [ -z $db_password ] || [ -z $db_host ] || [ -z $db_root_pass ] || [ -z $daytona_install_dir ] || [ -z $daytona_data_dir ] || [ -z $ui_admin_pass ] || [ -z $email_user ] || [ -z $email_domain ] || [ -z $smtp_server ] || [ -z $smtp_port ]; then
6+
echo 'one or more variables are undefined in config.sh'
7+
echo 'Please configure config.sh'
8+
echo 'For details that are unknown, enter some dummy values'
9+
exit 1
10+
fi
11+
12+
daytona_db_backup=$HOME/daytona_db_backup.sql
13+
daytona_data_backup=$HOME/daytona_data_backup.tar.gz
14+
15+
if [ ! -f $daytona_db_backup ] || [ ! -f $daytona_data_backup ]; then
16+
echo "Backup files not found at location : $HOME"
17+
exit 1
18+
fi
19+
20+
mysql -u ${db_user} -p${db_password} ${db_name} < $daytona_db_backup
21+
22+
cd $daytona_data_dir
23+
sudo tar -xvf $daytona_data_backup
24+
25+
cd -
26+
27+
cd $daytona_install_dir/Scheduler+Agent
28+
./restart_scheduler.sh
29+
30+
cd -
31+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
source config.sh
4+
5+
if [ -z $db_name ] || [ -z $db_user ] || [ -z $db_password ] || [ -z $db_host ] || [ -z $db_root_pass ] || [ -z $daytona_install_dir ] || [ -z $daytona_data_dir ] || [ -z $ui_admin_pass ] || [ -z $email_user ] || [ -z $email_domain ] || [ -z $smtp_server ] || [ -z $smtp_port ]; then
6+
echo 'one or more variables are undefined in config.sh'
7+
echo 'Please configure config.sh'
8+
echo 'For details that are unknown, enter some dummy values'
9+
exit 1
10+
fi
11+
12+
daytona_db_backup=$HOME/daytona_db_backup.sql
13+
daytona_data_backup=$HOME/daytona_data_backup.tar.gz
14+
15+
sudo rm -rf $daytona_db_backup $daytona_data_backup
16+
17+
mysqldump -u ${db_user} -p${db_password} ${db_name} > $daytona_db_backup
18+
19+
cd $daytona_data_dir
20+
sudo tar -cvf $daytona_data_backup .
21+
22+
cd -
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
source config.sh
4+
5+
if [ -z $db_name ] || [ -z $db_user ] || [ -z $db_password ] || [ -z $db_host ] || [ -z $db_root_pass ] || [ -z $daytona_install_dir ] || [ -z $daytona_data_dir ] || [ -z $ui_admin_pass ] || [ -z $email_user ] || [ -z $email_domain ] || [ -z $smtp_server ] || [ -z $smtp_port ]; then
6+
echo 'one or more variables are undefined in config.sh'
7+
echo 'Please configure config.sh'
8+
echo 'For details that are unknown, enter some dummy values'
9+
exit 1
10+
fi
11+
12+
daytona_db_backup=$HOME/daytona_db_backup.sql
13+
daytona_data_backup=$HOME/daytona_data_backup.tar.gz
14+
15+
if [ ! -f $daytona_db_backup ] || [ ! -f $daytona_data_backup ]; then
16+
echo "Backup files not found at location : $HOME"
17+
exit 1
18+
fi
19+
20+
mysql -u ${db_user} -p${db_password} ${db_name} < $daytona_db_backup
21+
22+
cd $daytona_data_dir
23+
sudo tar -xvf $daytona_data_backup
24+
25+
cd -
26+
27+
cd $daytona_install_dir/Scheduler+Agent
28+
./restart_scheduler.sh
29+
30+
cd -
31+

Scheduler+Agent/dbaccess.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,18 @@ def mon(self, *args):
106106
print self.cfg.mysql_host
107107
while True:
108108
self.db = DBAccess(self.cfg, self.lctx)
109+
query_result = self.db.query("""select testid from CommonFrameworkSchedulerQueue where state = %s or state = %s""", ("waiting", "scheduled"), True, False)
110+
test_list = [item[0] for item in query_result]
109111
d = "DBMON [W] : |"
110112
for k in self.tests_to_run:
111113
l = self.tests_to_run[k]
112114
for t in l :
113-
d = d + str(t.testobj.TestInputData.testid) + "|"
115+
if t.testobj.TestInputData.testid in test_list:
116+
d = d + str(t.testobj.TestInputData.testid) + "|"
117+
else:
118+
self.lock.acquire()
119+
self.tests_to_run[k].remove(t)
120+
self.lock.release()
114121
self.lctx.info(d)
115122
d = ""
116123

UI/js/main.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var isAdmin;
2+
var userid;
3+
14
function updateCurrentlyRunning(json_obj) {
25
var parentContainer = $('#currently-running');
36
$(parentContainer).empty();
@@ -33,10 +36,15 @@ function updateCurrentlyRunning(json_obj) {
3336
var td_username = $('<td></td>').text(json_obj[i].username);
3437
var td_state_detail = $('<td></td>').text(json_obj[i].state_detail);
3538
var td_start_time = $('<td></td>').text(json_obj[i].start_time);
36-
var td_kill = $('<td></td>').css('vertical-align', 'middle')
39+
if (isAdmin || userid == json_obj[i].username){
40+
var td_kill = $('<td></td>').css('vertical-align', 'middle')
3741
.append($('<a></a>').css('cursor', 'pointer')
3842
.append($('<i></i>').addClass('fa fa-times-circle fa-lg abort-btn'))
3943
.attr('onclick', 'killTest(' + json_obj[i].testid + ')'));
44+
}else{
45+
var td_kill = $('<td></td>');
46+
}
47+
4048
$(tr).append(td_frameworkname)
4149
.append(td_testid)
4250
.append(td_title)
@@ -98,13 +106,17 @@ function updateWaitingQueue(json_obj) {
98106
var td_title = $('<td></td>').text(json_obj[i].title);
99107
var td_username = $('<td></td>').text(json_obj[i].username);
100108
var td_state_detail = $('<td></td>').text(json_obj[i].state_detail);
101-
var td_kill = $('<td></td>')
102-
.css('vertical-align', 'middle')
103-
.append($('<a></a>')
104-
.css('cursor', 'pointer')
105-
.append($('<i></i>')
106-
.addClass('fa fa-times-circle fa-lg abort-btn'))
107-
.attr('onclick', 'killTest(' + json_obj[i].testid + ')'));
109+
if (isAdmin || userid == json_obj[i].username){
110+
var td_kill = $('<td></td>')
111+
.css('vertical-align', 'middle')
112+
.append($('<a></a>')
113+
.css('cursor', 'pointer')
114+
.append($('<i></i>')
115+
.addClass('fa fa-times-circle fa-lg abort-btn'))
116+
.attr('onclick', 'killTest(' + json_obj[i].testid + ')'));
117+
}else{
118+
var td_kill = $('<td></td>')
119+
}
108120
$(tr)
109121
.append(td_frameworkname)
110122
.append(td_testid)
@@ -217,8 +229,11 @@ function queryLastCompleted(frameworkId,user) {
217229
xhttp.send();
218230
}
219231

220-
function queryAll(frameworkId,user) {
232+
function queryAll(frameworkId,user,admin,userId) {
233+
isAdmin = admin;
234+
userid = userId;
221235
queryCurrentlyRunning(frameworkId,user);
222236
queryWaitingQueue(frameworkId,user);
223237
queryLastCompleted(frameworkId,user);
224238
}
239+

UI/js/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ $(".proc_filter_form").submit(function(e){
2424
e.preventDefault();
2525
div_id = this.div_id.value;
2626
title = this.title.value;
27-
28-
var proc_count = $("input[name='proc_list[]']:checked").length;
27+
checkbox_array = "input[name='proc_list" + div_id + "[]']:checked";
28+
var proc_count = $(checkbox_array).length;
2929
if (proc_count > MAX_PROCESS_COUNT){
3030
alert("Maximum " + MAX_PROCESS_COUNT + " process can be selected");
3131
return false;

UI/main.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@
6767
}else{
6868
user="2";
6969
}
70-
queryAll(<?php echo $frameworkId ?: 'undefined'; ?>,user);
70+
queryAll(<?php echo $frameworkId ?: 'undefined'; ?>, user, <?php echo $userIsAdmin ?>, '<?php echo $userId ?>');
7171
});
72-
queryAll(<?php echo $frameworkId ?: 'undefined'; ?>, "2");
72+
queryAll(<?php echo $frameworkId ?: 'undefined'; ?>, "2", <?php echo $userIsAdmin ?>, '<?php echo $userId ?>');
7373
setInterval(function() {
7474
var user;
7575
if($('input[name=owner]').prop("checked")){
7676
user="1";
7777
}else{
7878
user="2";
7979
}
80-
queryAll(<?php echo $frameworkId ?: 'undefined'; ?>, user);
81-
}, 10000);
80+
queryAll(<?php echo $frameworkId ?: 'undefined'; ?>, user, <?php echo $userIsAdmin ?>, '<?php echo $userId ?>');
81+
}, 2000);
8282
$("select[id=framework-select] option").each(function() {
8383
if($(this).text() == "<?php echo $frameworkName ?: ''; ?>") {
8484
$(this).attr('selected', 'selected');
@@ -88,3 +88,4 @@
8888
</script>
8989

9090
<?php include_once('lib/footer.php'); ?>
91+

0 commit comments

Comments
 (0)