Commit 843344d4 authored by Roque's avatar Roque

[hack opml response] tests use a local opml

parent 2405ccff
......@@ -9,6 +9,7 @@
stop = QUnit.stop,
start = QUnit.start,
deepEqual = QUnit.deepEqual,
DB_NAME = "monitoring_local_test.db",
slapos_master_url_list = ["https://panel.rapid.space/hateoas/", "https://softinst239021.host.vifib.net/erp5/web_site_module/slapos_hateoas/"];
rJS(window)
......@@ -28,7 +29,7 @@
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoring_local_roque.db"
database: DB_NAME
}
}
},
......
......@@ -9,6 +9,7 @@
stop = QUnit.stop,
start = QUnit.start,
deepEqual = QUnit.deepEqual,
DB_NAME = "monitoring_local_test.db",
slapos_master_url_list = ["https://panel.rapid.space/hateoas/", "https://softinst239021.host.vifib.net/erp5/web_site_module/slapos_hateoas/"];
rJS(window)
......@@ -28,7 +29,7 @@
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoring_local_roque.db"
database: DB_NAME
}
}
},
......@@ -43,7 +44,7 @@
url: slapos_master_url_list[0],
default_view_reference: "jio_view"
}
},
}/*,
{
type: "erp5monitor",
limit: 20,
......@@ -52,7 +53,7 @@
url: slapos_master_url_list[1],
default_view_reference: "jio_view"
}
}
}*/
]
}
});
......@@ -64,27 +65,21 @@
var jio, jio_definition = jio_options,
first_master_total_docs, opml_foo_url = "https://foo-opml.bar";
stop();
expect(25);
try {
jio = jIO.createJIO(jio_options);
} catch (error) {
console.error(error.stack);
console.error(error);
throw error;
}
// Try to fetch inexistent document
jio.get("inexistent")
.fail(function (error) {
if (error.status_code !== 404) {
throw error;
}
equal(error.status_code, 404, "404 if inexistent");
//Ensure no previous test db is present
return new RSVP.Queue()
.push(function () {
return indexedDB.deleteDatabase("jio:" + DB_NAME);
})
.then(function () {
try {
jio = jIO.createJIO(jio_options);
} catch (error) {
console.error(error.stack);
console.error(error);
throw error;
}
//first sync
console.log("Sync for master 1 and 2");
return jio.repair();
})
.fail(function (error) {
......@@ -95,218 +90,38 @@
})
//check if repair minimally worked
.then(function () {
return jio.allDocs();
})
.then(function (all_docs) {
ok(all_docs.data.total_rows > 0, 'Repair succeded. (if not, please be sure to be logged in masters)');
})
//TODO test allAttachments
//call methods that are not implemented (fail expected)
.then(function () {
return jio.getAttachment("foo", "bar");
})
.fail(function (error) {
if (error.status_code !== 501) {
throw error;
}
equal(error.status_code, 501, "400 if no getAttachment method");
})
.then(function () {
return jio.putAttachment("foo",
"bar",
new Blob(["fooo"], {type: "text/plain"}));
})
.fail(function (error) {
if (error.status_code !== 501) {
throw error;
}
equal(error.status_code, 501, "501 if no putAttachment method");
})
.then(function () {
return jio.post({});
})
.fail(function (error) {
if (error.status_code !== 501) {
throw error;
}
equal(error.status_code, 501, "501 if no post method");
})
//check limit and sort are implemented
.then(function () {
return jio.allDocs({limit: [0, 3], sort_on: [["creation_date", "descending"]]});
})
//check specific type of objects were created after repair
.then(function (all_docs) {
ok(all_docs.data.total_rows === 3, 'Limit capacity implemented.');
return RSVP.all([
jio.allDocs({query: 'portal_type: "Instance Tree"'}),
jio.allDocs({query: 'portal_type: "Software Instance"'}),
jio.allDocs({query: 'portal_type: "Promise"'}),
jio.allDocs({query: 'portal_type: "Opml"'}),
jio.allDocs({query: 'portal_type: "Opml Outline"'}),
jio.allDocs({include_docs: true}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[0] + '"'}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[1] + '"'})
jio.allDocs({include_docs: true})
]);
})
.then(function (all_doc_list) {
var id_list = [], get_list = [], all_docs = all_doc_list[5].data.rows, i, push_queue = new RSVP.Queue();
first_master_total_docs = all_doc_list[6].data.total_rows;
console.log("Objects created for master 1:", first_master_total_docs);
console.log("Objects created for master 2:", all_doc_list[7].data.total_rows);
ok(first_master_total_docs > 0, 'Objects created for master 1.');
ok(all_doc_list[7].data.total_rows > 0, 'Objects created for master 2.');
console.log("all_doc_list", all_doc_list);
ok(all_doc_list[5].data.total_rows > 0, 'Repair succeded. (if not, please be sure to be logged in masters)');
ok(all_doc_list[0].data.total_rows > 0, 'Instance Tree object created after sync.');
id_list.push(all_doc_list[0].data.rows[0].id); //save one id to check later in all docs
ok(all_doc_list[1].data.total_rows > 0, 'Software Instance object created after sync.');
id_list.push(all_doc_list[1].data.rows[0].id);
ok(all_doc_list[2].data.total_rows > 0, 'Promise object created after sync.');
id_list.push(all_doc_list[2].data.rows[0].id);
ok(all_doc_list[3].data.total_rows > 0, 'Opml object created after sync.');
id_list.push(all_doc_list[3].data.rows[0].id);
ok(all_doc_list[4].data.total_rows > 0, 'Opml Outline object created after sync.');
id_list.push(all_doc_list[4].data.rows[0].id);
for (i = 0; i < id_list.length; i += 1) {
var idd = id_list[i];
get_list.push(jio.get(idd));
}
for (i = 0; i < all_docs.length; i += 1) {
//check different elements are present in plain allDocs
if (id_list.includes(all_docs[i].id)) {
const index = id_list.indexOf(all_docs[i].id);
id_list.splice(index, 1);
}
//check all attachments
var i, push_queue = new RSVP.Queue();
function pushAll(id) {
push_queue
.push(function () {
return jio.allAttachments(id);
});
}
ok(id_list.length === 0, 'Different types created objects are returned by allDocs');
console.log("Total amount of docs after first repair:", all_docs.length);
return RSVP.all(get_list);
})
.then(function (get_list_result) {
//check specific objects
equal(get_list_result[0].portal_type, "Instance Tree", "Check instance tree object.");
equal(get_list_result[1].portal_type, "Software Instance", "Check software instance object.");
equal(get_list_result[2].portal_type, "Promise", "Check promise tree object.");
equal(get_list_result[3].portal_type, "Opml", "Check opml object.");
equal(get_list_result[4].portal_type, "Opml Outline", "Check opml outline object.");
//update jio storage slapos master urls (drop one)
jio_definition.remote_sub_storage.storage_list = [
{
type: "erp5monitor",
limit: 20,
sub_storage: {
type: "erp5",
url: slapos_master_url_list[0],
default_view_reference: "jio_view"
}
}
];
try {
jio = jIO.createJIO(jio_options);
} catch (error) {
console.error(error.stack);
console.error(error);
throw error;
for (i = 0; i < all_doc_list[5].data.rows.length; i += 1) {
pushAll(all_doc_list[5].data.rows[i].id);
}
console.log("Sync for only master 1 (master 2 removed)");
return jio.repair();
})
.then(function () {
//check objects for each slapos master
return RSVP.all([
jio.allDocs({include_docs: true}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[0] + '"'}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[1] + '"'})
]);
})
.then(function (all_results) {
console.log("Total amount of docs after second repair:", all_results[0].data.total_rows);
console.log("Objects from master 1:", all_results[1].data.total_rows);
console.log("Objects from master 2:", all_results[2].data.total_rows);
ok(all_results[1].data.total_rows === first_master_total_docs, "Objects of kept master url must be kept");
ok(all_results[2].data.total_rows === 0, "Removed master url objects must be removed");
})
.then(function () {
//manually add an opml
var opml_dict = {
type: "Opml",
title: "foo opml",
portal_type: "Opml",
url: opml_foo_url,
basic_login: "basic_login",
username: "username",
password: "password",
active: true,
has_monitor: true,
state: "Started",
slapos_master_url: "foo-master",
manually_added: true
};
return jio.put(opml_foo_url, opml_dict);
})
.then(function () {
console.log("Sync for ompl manually added (master 1 kept)");
return jio.repair();
})
.then(function () {
return RSVP.all([
jio.allDocs({include_docs: true}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[0] + '"'}),
jio.get(opml_foo_url),
jio.allDocs({query: 'slapos_master_url: ""'})
]);
})
.then(function (all_results) {
console.log("Total amount of docs after third repair:", all_results[0].data.total_rows);
console.log("From manual opml (no master):", all_results[3].data.total_rows);
equal(all_results[2].url, opml_foo_url, "Opml was added.");
//check new objects were created, besides ompl itself and previous master ones
ok(all_results[0].data.total_rows >= first_master_total_docs + 1, "New objects created for added opml");
})
//TODO change masters and sync, and then check ompl and its objects are kept?
.then(function () {
//remove opml
return jio.remove(opml_foo_url);
})
.then(function () {
console.log("Sync for removed ompl (master 1 kept)");
return jio.repair();
})
.then(function () {
return RSVP.all([
jio.allDocs({include_docs: true}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[0] + '"'})
]);
})
.then(function (all_results) {
//check opml objects were removed too
console.log("Total amount of docs after fourth repair:", all_results[0].data.total_rows);
ok(all_results[0].data.total_rows === first_master_total_docs && all_results[1].data.total_rows === first_master_total_docs, "Objects of kept master url must be kept");
return jio.get(opml_foo_url);
return push_queue;
})
.fail(function (error) {
if (error.status_code !== 404) {
throw error;
}
equal(error.status_code, 404, "Opml was removed.");
})
.then(function () {
return RSVP.all([
jio.allDocs({include_docs: true}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[0] + '"'}),
jio.allDocs({query: 'slapos_master_url: "' + slapos_master_url_list[1] + '"'}),
jio.allDocs({query: 'slapos_master_url: ""'})
]);
})
.then(function (all_results) {
console.log("Finished. Total amount of docs:", all_results[0].data.total_rows);
console.log("From master 1:", all_results[1].data.total_rows);
console.log("From master 2:", all_results[2].data.total_rows);
console.log("No master (manual opml)):", all_results[3].data.total_rows);
console.log("Full doc list:", all_results);
ok(false, error);
})
.always(function () {
start();
......
......@@ -6,9 +6,6 @@
var rusha = new Rusha(),
mock_test = true,
MOCK_OPMLS = '[{"id":"/0","value":{},"doc":{"dateModified":"Thu, 04 Jul 2024 18:48:28 +0000","dateCreated":"Thu, 04 Jul 2024 09:00:47 +0000","title":"ERP5 Playground instance"}},{"id":"/1/0","value":{},"doc":{"text":"Monitoring RSS Feed list"}},{"id":"/1/0/3","value":{},"doc":{"url":"https://softinst220514.host.vifib.net/share/private/","xmlUrl":"https://softinst220514.host.vifib.net/public/feed","htmlUrl":"https://softinst220514.host.vifib.net/public/feed","version":"RSS","type":"rss","title":"PBS COMP-3557-theia-1","text":"PBS COMP-3557-theia-1","portal_type":"Opml Outline","parent_id":"f185fe2fa2280798a181e3fa45d2cad763d10540","parent_url":"https://softinst184163.host.vifib.net/public/feeds","reference":"2f9748e8ec9656b70ebf08dfec841509d506a8aa","active":true,"dateCreated":"Thu, 04 Jul 2024 09:00:47 +0000","dateModified":"Thu, 04 Jul 2024 18:48:28 +0000","opml_title":"ERP5 Playground instance"}},{"id":"/1/0/2","value":{},"doc":{"url":"https://softinst184178.host.vifib.net/share/private/","xmlUrl":"https://softinst184178.host.vifib.net/public/feed","htmlUrl":"https://softinst184178.host.vifib.net/public/feed","version":"RSS","type":"rss","title":"theia1","text":"theia1","portal_type":"Opml Outline","parent_id":"f185fe2fa2280798a181e3fa45d2cad763d10540","parent_url":"https://softinst184163.host.vifib.net/public/feeds","reference":"e5a8721558fba656175533e09b5023b24ad1aeed","active":true,"dateCreated":"Thu, 04 Jul 2024 09:00:47 +0000","dateModified":"Thu, 04 Jul 2024 18:48:28 +0000","opml_title":"ERP5 Playground instance"}},{"id":"/1/0/1","value":{},"doc":{"url":"https://softinst184170.host.vifib.net/share/private/","xmlUrl":"https://softinst184170.host.vifib.net/public/feed","htmlUrl":"https://softinst184170.host.vifib.net/public/feed","version":"RSS","type":"rss","title":"theia0","text":"theia0","portal_type":"Opml Outline","parent_id":"f185fe2fa2280798a181e3fa45d2cad763d10540","parent_url":"https://softinst184163.host.vifib.net/public/feeds","reference":"62bcecf32735232bf9b4fde41698bbe743dcd438","active":true,"dateCreated":"Thu, 04 Jul 2024 09:00:47 +0000","dateModified":"Thu, 04 Jul 2024 18:48:28 +0000","opml_title":"ERP5 Playground instance"}},{"id":"/1/0/0","value":{},"doc":{"url":"https://softinst184163.host.vifib.net/share/private/","xmlUrl":"https://softinst184163.host.vifib.net/public/feed","htmlUrl":"https://softinst184163.host.vifib.net/public/feed","version":"RSS","type":"rss","title":"ERP5 Playground instance","text":"ERP5 Playground instance","portal_type":"Opml Outline","parent_id":"f185fe2fa2280798a181e3fa45d2cad763d10540","parent_url":"https://softinst184163.host.vifib.net/public/feeds","reference":"305ddc8bed6419578add7a4cb19a0960a9b8a89d","active":true,"dateCreated":"Thu, 04 Jul 2024 09:00:47 +0000","dateModified":"Thu, 04 Jul 2024 18:48:28 +0000","opml_title":"ERP5 Playground instance"}}]',
MOCK_PROMISE = '{"data":{"rows":[{"id":"/0","value":{},"doc":{"docs":"http://blogs.law.harvard.edu/tech/rss","generator":"PyRSS2Gen-1.1.0","lastBuildDate":"Thu, 04 Jul 2024 23:04:14 GMT","description":"ERP5 Playground instance","link":"https://softinst220514.host.vifib.net/public/feed","title":"PBS COMP-3557-theia-1"}},{"id":"/0/0","value":{},"doc":{"source":"check-free-disk-space","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:12:11+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBjaGVjay1mcmVlLWRpc2stc3BhY2UsIDAyYTA1MWVmMjYwYWM3Y2RiNDE5ZmMwOTljNDRlM2U3LCAyMDI0LTA1LTEyVDA1OjEyOjExKzAwMDA=","guid_isPermaLink":"false","category":"OK","description":"Current disk usage: OKEnable to display disk space predictions: False","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] check-free-disk-space"}},{"id":"/0/1","value":{},"doc":{"source":"ssh-to-COMP-3557-slappart27-theia-1-pull","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-07-04T20:42:10+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBzc2gtdG8tQ09NUC0zNTU3LXNsYXBwYXJ0MjctdGhlaWEtMS1wdWxsLCBkNDFkOGNkOThmMDBiMjA0ZTk4MDA5OThlY2Y4NDI3ZSwgMjAyNC0wNy0wNFQyMDo0MjoxMCswMDAw","guid_isPermaLink":"false","category":"OK","description":"","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] ssh-to-COMP-3557-slappart27-theia-1-pull"}},{"id":"/0/2","value":{},"doc":{"source":"buildout-slappart46-status","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:46+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBidWlsZG91dC1zbGFwcGFydDQ2LXN0YXR1cywgODY1MzBjNTE5MmIwMzA1MjlhODJiZTY1NDZkMWI5MmYsIDIwMjQtMDUtMTJUMDU6MzA6NDYrMDAwMA==","guid_isPermaLink":"false","category":"OK","description":"buildout is OK","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] buildout-slappart46-status"}},{"id":"/0/3","value":{},"doc":{"source":"notifier-feed-check-malformed-or-failure","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:45+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBub3RpZmllci1mZWVkLWNoZWNrLW1hbGZvcm1lZC1vci1mYWlsdXJlLCA1NTZiNThmNzE3ZjY5Yjk0M2Q1NTc1YTZjNGU3M2U2YiwgMjAyNC0wNS0xMlQwNTozMDo0NSswMDAw","guid_isPermaLink":"false","category":"OK","description":"OK /srv/slapgrid/slappart46/bin/notifier-feed-check-malformed-or-failure.py run with success","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] notifier-feed-check-malformed-or-failure"}},{"id":"/0/4","value":{},"doc":{"source":"monitor-httpd-listening-on-tcp","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:46+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBtb25pdG9yLWh0dHBkLWxpc3RlbmluZy1vbi10Y3AsIDhkYmE4OTAyMTcxNzRhNzdhMzM5NWVkNjI0MWE0Y2Y5LCAyMDI0LTA1LTEyVDA1OjMwOjQ2KzAwMDA=","guid_isPermaLink":"false","category":"OK","description":"non-authenticated request to https://[2001:67c:1254:103::5975]:8070 succeeded (returned expected code 401)","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] monitor-httpd-listening-on-tcp"}},{"id":"/0/5","value":{},"doc":{"source":"ssh-to-COMP-3557-slappart27-theia-1-push","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-07-04T22:54:25+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBzc2gtdG8tQ09NUC0zNTU3LXNsYXBwYXJ0MjctdGhlaWEtMS1wdXNoLCBkNDFkOGNkOThmMDBiMjA0ZTk4MDA5OThlY2Y4NDI3ZSwgMjAyNC0wNy0wNFQyMjo1NDoyNSswMDAw","guid_isPermaLink":"false","category":"OK","description":"","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] ssh-to-COMP-3557-slappart27-theia-1-push"}},{"id":"/0/6","value":{},"doc":{"source":"check-monitor-frontend-password","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:46+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBjaGVjay1tb25pdG9yLWZyb250ZW5kLXBhc3N3b3JkLCA1YWRjMTAzMDhiYWVhYWJmMWZhZDIyMDBjOTQ0ODc2OSwgMjAyNC0wNS0xMlQwNTozMDo0NiswMDAw","guid_isPermaLink":"false","category":"OK","description":"authenticated request to https://softinst220514.host.vifib.net succeeded (returned expected code 200)","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] check-monitor-frontend-password"}},{"id":"/0/7","value":{},"doc":{"source":"stalled-pull-push","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:46+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBzdGFsbGVkLXB1bGwtcHVzaCwgZWI3Mjc5NWJlM2IzYTQwNjg1Nzg3YTk0NWFmMTcyZjEsIDIwMjQtMDUtMTJUMDU6MzA6NDYrMDAwMA==","guid_isPermaLink":"false","category":"OK","description":"OK /srv/slapgrid/slappart46/bin/stalled-pull-push run with success","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] stalled-pull-push"}},{"id":"/0/8","value":{},"doc":{"source":"monitor-bootstrap-status","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:46+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBtb25pdG9yLWJvb3RzdHJhcC1zdGF0dXMsIGY2MjBiYTUxMjc4Y2U3YjIxZjlhNzg1ZDc4OThkZThjLCAyMDI0LTA1LTEyVDA1OjMwOjQ2KzAwMDA=","guid_isPermaLink":"false","category":"OK","description":"Bootstrap OK","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] monitor-bootstrap-status"}},{"id":"/0/9","value":{},"doc":{"source":"monitor-http-frontend","source_url":"https://softinst220514.host.vifib.net/share/public/","pubDate":"2024-05-12T05:30:45+0000","guid":"RVJQNSBQbGF5Z3JvdW5kIGluc3RhbmNlLCBtb25pdG9yLWh0dHAtZnJvbnRlbmQsIDNiMTcwYjc0Njk0MTNjMTUxZTkxMmU5MDI4ZjFjNWVkLCAyMDI0LTA1LTEyVDA1OjMwOjQ1KzAwMDA=","guid_isPermaLink":"false","category":"OK","description":"non-authenticated request to https://softinst220514.host.vifib.net succeeded (returned expected code 401)","link":"https://softinst220514.host.vifib.net/share/private/","title":"[OK] monitor-http-frontend"}}],"total_rows":11}}',
MOCK_INSTANCE = '{"data":{"rows":[{"id":"monitor.global","value":{},"doc":{"status":"OK","state":{"error":0,"success":21},"type":"global","portal_type":"Software Instance","date":"2024-07-04T23:10:20+0000","_links":{"rss_url":{"href":"https://softinst184178.host.vifib.net/public/feed"},"public_url":{"href":"https://softinst184178.host.vifib.net/share/public/"},"private_url":{"href":"https://softinst184178.host.vifib.net/share/private/"},"related_monitor":[]},"data":{"state":"monitor_state.data","process_state":"monitor_process_resource.status","process_resource":"monitor_resource_process.data","memory_resource":"monitor_resource_memory.data","io_resource":"monitor_resource_io.data","monitor_process_state":"monitor_resource.status"},"title":"theia1","specialise_title":"ERP5 Playground instance","aggregate_reference":"COMP-3490","ipv4":"10.0.225.11","ipv6":"2001:67c:1254:f1::f6f0","software_release":"https://lab.nexedi.com/nexedi/slapos/raw/1.0.358/software/theia/software.cfg","software_type":"import","partition_id":"slappart30","parameters":[{"key":"","title":"monitor-user","value":"admin"},{"key":"monitor-password","title":"monitor-password","value":"CQo1zXbIB0XqAwYt"},{"key":"min-free-disk-MB","title":"min-free-disk-MB","value":""}]}}],"total_rows":1}}',
OPML_ATTACHMENT_NAME = "__opml__",
PROMISE_TYPE = "Promise",
SOFTWARE_INSTANCE_TYPE = "Software Instance",
......@@ -355,15 +352,7 @@
return sub_storage.allDocs({include_docs: true})
.push(undefined, function (error) {
//throw error;
console.error(error);
if (mock_test) {
if (index === 2) {
return JSON.parse(MOCK_PROMISE);
}
if (index === 3) {
return JSON.parse(MOCK_INSTANCE);
}
}
console.error("sub storage error:", error);
return undefined;
})
.push(function (result) {
......@@ -438,6 +427,7 @@
id = generateHash(opml_url);
opml_storage = createStorage(context, opml_spec, id);
console.log("creating opml_storage with opml_url and opml_spec:", opml_url, opml_spec);
// Instance Tree is build from OPML and it has status
instance_tree = {
......@@ -460,6 +450,7 @@
if (fetch_remote_opml) {
return opml_storage.allDocs({include_docs: true})
.push(undefined, function (error) {
console.log("opml_storage.allDocs ERROR:", error);
if ((error instanceof jIO.util.jIOError) &&
(error.status_code === 404)) {
return {data: {total_rows: 0}};
......@@ -469,6 +460,9 @@
return {data: {total_rows: 0}};
})
.push(function (opml_result) {
if (opml_result.data.rows) {
console.log("NO CORS error!");
}
opml_result_list = opml_result;
if (opml_result.data.total_rows > 0) {
attachment_document_list.push({
......@@ -518,11 +512,6 @@
}
}
var iter = opml_result_list.data.total_rows;
if (mock_test) {
opml_result_list.data.rows = JSON.parse(MOCK_OPMLS);
opml_result_list.data.total_rows = 6;
iter = 4;
}
for (i = 1; i < iter; i += 1) {
item = opml_result_list.data.rows[i];
if (item.doc.xmlUrl !== undefined) {
......@@ -938,6 +927,10 @@
select_list: ['title', 'default_successor_uid', 'uid', 'slap_state', 'id']
})
.push(function (result) {
if (mock_test) {
result.data.total_rows = 1;
result.data.rows = [result.data.rows[0]];
}
var i, slapos_id, slapos_master_url = "",
uid_search_list = [];
for (i = 0; i < result.data.total_rows; i += 1) {
......@@ -983,6 +976,13 @@
if (tmp_parameter === undefined) {
tmp_parameter = {username: "", password: "", opml_url: undefined};
}
if (mock_test) {
tmp_parameter.opml_url = "https://softinst238949.host.vifib.net/public/feeds";
tmp_parameter.password = "C1r796U05Z64QMyk";
//tmp_parameter.opml_url = "https://softinst239780.host.vifib.net/public/feeds";
//tmp_parameter.password = "07b17cifhSKxNdot";
tmp_parameter.username = "admin";
}
if (instance_tree_list[uid_dict[tmp_uid]]) {
if (result.data.rows[i].master_url) {
slapos_master_url = result.data.rows[i].master_url;
......@@ -1101,9 +1101,10 @@
throw "Failed to import remote configurations" + error_msg;
})
.push(function (opml_list) {
console.log(opml_list);
//HARDCODED second master
if (mock_test) {
/*if (mock_test) {
if (context._remote_sub_storage.__storage._storage_list[1]) {
if (context._remote_sub_storage.__storage._storage_list[1].__storage._storage_definition.url === "https://softinst239021.host.vifib.net/erp5/web_site_module/slapos_hateoas/") {
opml_list[6].slapos_master_url = "https://softinst239021.host.vifib.net/erp5/web_site_module/slapos_hateoas/";
......@@ -1111,7 +1112,7 @@
} else {
opml_list.pop();
}
}
}*/
//store opmls in local sub storage
var i, push_queue = new RSVP.Queue();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment