Skip to content

Commit

Permalink
Update MW topology tests to include two new server types
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala committed Nov 30, 2017
1 parent 25a0da6 commit b5d2ae6
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ describe('middlewareTopologyController', function () {
}
};

var mw_server_wildfly = {
id: "MiddlewareServerWildfly1", item: {
"name": "Local DMR",
"kind": "MiddlewareServerWildfly",
"miq_id": 1,
"status": "Running",
"display_kind": "MiddlewareServerWildfly",
"icon": "vendor-wildfly"
}
};

var mw_server_eap = {
id: "MiddlewareServerEap1", item: {
"name": "Local DMR",
"kind": "MiddlewareServerEap",
"miq_id": 1,
"status": "Running",
"display_kind": "MiddlewareServerEap",
"icon": "vendor-eap"
}
};

var mw_server_starting = {
id: "MiddlewareServer1", item: {
"status": "Starting"
Expand Down Expand Up @@ -162,9 +184,11 @@ describe('middlewareTopologyController', function () {

describe('kinds contains all expected mw kinds', function () {
it('in all main objects', function () {
expect(Object.keys(scope.kinds).length).toBe(8);
expect(Object.keys(scope.kinds).length).toBe(10);
expect(ctrl.kinds["MiddlewareManager"]).toBeDefined();
expect(ctrl.kinds["MiddlewareServer"]).toBeDefined();
expect(ctrl.kinds["MiddlewareServerEap"]).toBeDefined();
expect(ctrl.kinds["MiddlewareServerWildfly"]).toBeDefined();
expect(ctrl.kinds["MiddlewareDeployment"]).toBeDefined();
expect(ctrl.kinds["MiddlewareDatasource"]).toBeDefined();
expect(ctrl.kinds["Vm"]).toBeDefined();
Expand All @@ -179,6 +203,8 @@ describe('middlewareTopologyController', function () {
it('in graph elements', function () {
expect(ctrl.getIcon(mw_manager).icon).toContain("vendor-hawkular");
expect(ctrl.getIcon(mw_server).icon).toContain("vendor-wildfly");
expect(ctrl.getIcon(mw_server_wildfly).icon).toContain("vendor-wildfly");
expect(ctrl.getIcon(mw_server_eap).icon).toContain("vendor-jboss-eap");
expect(ctrl.getIcon(mw_deployment).fontfamily).toEqual("font-fabulous");
expect(ctrl.getIcon(mw_datasource).fontfamily).toEqual("FontAwesome");
expect(ctrl.getIcon(vm).fontfamily).toEqual("PatternFlyIcons-webfont");
Expand All @@ -192,6 +218,8 @@ describe('middlewareTopologyController', function () {
it('for all objects', function () {
expect(ctrl.getCircleDimensions(mw_manager)).toEqual({x: -20, y: -20, height: 40, width: 40, r: 28});
expect(ctrl.getCircleDimensions(mw_server)).toEqual({x: -12, y: -12, height: 23, width: 23, r: 19});
expect(ctrl.getCircleDimensions(mw_server_eap)).toEqual({x: -9, y: -9, height: 18, width: 18, r: 17});
expect(ctrl.getCircleDimensions(mw_server_wildfly)).toEqual({x: -9, y: -9, height: 18, width: 18, r: 17});
expect(ctrl.getCircleDimensions(mw_deployment)).toEqual({x: -9, y: -9, height: 18, width: 18, r: 17});
expect(ctrl.getCircleDimensions(mw_datasource)).toEqual({x: -9, y: -9, height: 18, width: 18, r: 17});
expect(ctrl.getCircleDimensions(vm)).toEqual({ x: 0, y: 9, height: 40, width: 40, r: 21 });
Expand All @@ -205,6 +233,8 @@ describe('middlewareTopologyController', function () {
it('for all objects', function () {
expect(ctrl.getIcon(mw_manager).type).toEqual("image");
expect(ctrl.getIcon(mw_server).type).toEqual("image");
expect(ctrl.getIcon(mw_server_wildfly).type).toEqual("image");
expect(ctrl.getIcon(mw_server_eap).type).toEqual("image");
expect(ctrl.getIcon(mw_deployment).type).toEqual("glyph");
expect(ctrl.getIcon(mw_datasource).type).toEqual("glyph");
expect(ctrl.getIcon(vm).type).toEqual("glyph");
Expand All @@ -222,6 +252,8 @@ describe('middlewareTopologyController', function () {
});
it('for servers', function() {
expect(topologyService.getItemStatusClass(mw_server)).toEqual('success');
expect(topologyService.getItemStatusClass(mw_server_wildfly)).toEqual('success');
expect(topologyService.getItemStatusClass(mw_server_eap)).toEqual('success');
expect(topologyService.getItemStatusClass(mw_server_down)).toEqual('error');
expect(topologyService.getItemStatusClass(mw_server_starting)).toEqual('information');
expect(topologyService.getItemStatusClass(mw_server_reload)).toEqual('warning');
Expand Down
26 changes: 26 additions & 0 deletions spec/javascripts/fixtures/json/middleware_topology_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
"display_kind": "MiddlewareServer",
"icon": "vendor-wildfly"
},
"MiddlewareServerWildfly1": {
"name": "Local DMR",
"kind": "MiddlewareServerWildfly",
"miq_id": 1,
"status": "Unknown",
"display_kind": "MiddlewareServerWildfly",
"icon": "vendor-wildfly"
},
"MiddlewareServerEap1": {
"name": "Local DMR",
"kind": "MiddlewareServerEap",
"miq_id": 1,
"status": "Unknown",
"display_kind": "MiddlewareServerEap",
"icon": "vendor-jboss-eap"
},
"MiddlewareDeployment1": {
"name": "hawkular-command-gateway-war.war",
"kind": "MiddlewareDeployment",
Expand Down Expand Up @@ -79,6 +95,14 @@
"source": "MiddlewareManager1",
"target": "MiddlewareServer1"
},
{
"source": "MiddlewareManager1",
"target": "MiddlewareServerEap1"
},
{
"source": "MiddlewareManager1",
"target": "MiddlewareServerWildfly1"
},
{
"source": "MiddlewareServer1",
"target": "MiddlewareDeployment1"
Expand Down Expand Up @@ -119,6 +143,8 @@
"MiddlewareManager": true,
"Vm": true,
"MiddlewareServer": true,
"MiddlewareServerEap": true,
"MiddlewareServerWildfly": true,
"MiddlewareServerGroup": true,
"MiddlewareMessaging": true
},
Expand Down
85 changes: 74 additions & 11 deletions spec/services/middleware_topology_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
let(:long_id_5) { "Local~/deployment=hawkular-command-gateway-war.war" }
let(:long_id_6) { "Local~/subsystem=datasources/data-source=ExampleDS" }
let(:long_id_7) { "Local~/subsystem=messaging-activemq/server=default/jms-topic=HawkularMetricData" }
let(:long_id_8) { "/t;28026b36-8fe4-4332-84c8-524e173a68bf/f;fabf8d822986/r;Local%20DMR~~" }
let(:long_id_9) { "/t;28026b36-8fe4-4332-84c8-524e173a68bf/f;unused-4-252.brq.redhat.com/r;Local%20DMR~~" }

describe "#build_topology" do
subject { middleware_topology_service.build_topology }
Expand All @@ -23,6 +25,27 @@
:properties => { 'Calculated Server State' => 'running' })
end

let!(:mw_server_wildfly) do
FactoryGirl.create(:hawkular_middleware_server_wildfly,
:name => 'Local DMR',
:feed => 'fabf8d822986',
:ems_ref => long_id_0,
:nativeid => 'Local DMR~~',
:ext_management_system => ems_hawkular,
:properties => { 'Calculated Server State' => 'running' })
end

let!(:mw_server_eap) do
FactoryGirl.create(:hawkular_middleware_server_eap,
:name => 'Local DMR',
:feed => 'unused-4-252.brq.redhat.com',
:ems_ref => long_id_0,
:nativeid => 'Local DMR~~',
:ext_management_system => ems_hawkular,
:product => 'EAP',
:properties => { 'Calculated Server State' => 'running', 'product' => 'EAP' })
end

before do
allow(middleware_topology_service).to receive(:retrieve_providers).and_return([ems_hawkular])
end
Expand Down Expand Up @@ -76,6 +99,28 @@
:key => "MiddlewareServer" + mw_server.compressed_id.to_s}
)

expect(subject[:items]).to include(
"MiddlewareServerEap" + mw_server_eap.compressed_id.to_s => {:name => mw_server_eap.name,
:status => "Running",
:kind => "MiddlewareServerEap",
:display_kind => "MiddlewareServerEap",
:miq_id => mw_server_eap.id,
:icon => match(/vendor-jboss-eap/),
:model => mw_server_eap.class.name,
:key => "MiddlewareServerEap" + mw_server_eap.compressed_id.to_s}
)

expect(subject[:items]).to include(
"MiddlewareServerWildfly" + mw_server_wildfly.compressed_id.to_s => {:name => mw_server_wildfly.name,
:status => "Running",
:kind => "MiddlewareServerWildfly",
:display_kind => "MiddlewareServerWildfly",
:miq_id => mw_server_wildfly.id,
:icon => match(/vendor-wildfly/),
:model => mw_server_wildfly.class.name,
:key => "MiddlewareServerWildfly" + mw_server_wildfly.compressed_id.to_s}
)

expect(subject[:items]).to include(
"MiddlewareDeployment" + mw_deployment1.compressed_id.to_s => {:name => mw_deployment1.name,
:status => "Enabled",
Expand Down Expand Up @@ -116,18 +161,36 @@
:key => "MiddlewareMessaging" + mw_messaging.compressed_id.to_s}
)

expect(subject[:relations].size).to eq(5)
expect(subject[:relations].size).to eq(7)
expect(subject[:relations]).to include(
{:source => "MiddlewareManager" + ems_hawkular.compressed_id.to_s,
:target => "MiddlewareServer" + mw_server.compressed_id.to_s},
{:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareDeployment" + mw_deployment1.compressed_id.to_s},
{:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareDeployment" + mw_deployment2.compressed_id.to_s},
{:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareDatasource" + mw_datasource.compressed_id.to_s},
{:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareMessaging" + mw_messaging.compressed_id.to_s}
{
:source => "MiddlewareManager" + ems_hawkular.compressed_id.to_s,
:target => "MiddlewareServer" + mw_server.compressed_id.to_s
},
{
:source => "MiddlewareManager" + ems_hawkular.compressed_id.to_s,
:target => "MiddlewareServerEap" + mw_server_eap.compressed_id.to_s
},
{
:source => "MiddlewareManager" + ems_hawkular.compressed_id.to_s,
:target => "MiddlewareServerWildfly" + mw_server_wildfly.compressed_id.to_s
},
{
:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareDeployment" + mw_deployment1.compressed_id.to_s
},
{
:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareDeployment" + mw_deployment2.compressed_id.to_s
},
{
:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareDatasource" + mw_datasource.compressed_id.to_s
},
{
:source => "MiddlewareServer" + mw_server.compressed_id.to_s,
:target => "MiddlewareMessaging" + mw_messaging.compressed_id.to_s
}
)
end

Expand Down

0 comments on commit b5d2ae6

Please sign in to comment.