Skip to content

Commit

Permalink
[Build] Dashboards working with legacy engines 7.10.2
Browse files Browse the repository at this point in the history
Enables the version check to work specifically in the case of OSD 1.X and
legacy 7.10.2. This will avoid conflicts in future versions of the application
where Dashboards is not compatible with the Engines on version differences.

Testing for verifying compatible legacy version.

Issues resolved:
opensearch-project#720

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Aug 17, 2021
1 parent ea9e742 commit e08432d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ describe('plugins/opensearch', () => {
it('when majors are equal, but OpenSearch minor is less than OpenSearch Dashboards minor', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('1.0.0', '1.1.0')).toBe(false);
});

it('when majors and minors are not equal, but the engine is on legacy version 6.10.3 and OpenSearch Dashboards is on 1.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('6.10.3', '1.0.0')).toBe(false);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.3 and OpenSearch Dashboards is on 1.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.3', '1.0.0')).toBe(false);
});

it('when majors and minors are not equal, but the engine is on legacy version 8.0.0 and OpenSearch Dashboards is on 1.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('8.0.0', '1.0.0')).toBe(false);
});
});

describe('returns true', () => {
Expand All @@ -64,6 +76,18 @@ describe('plugins/opensearch', () => {
it('when majors and minors are equal, but OpenSearch patch is less than OpenSearch Dashboards patch', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('1.1.0', '1.1.1')).toBe(true);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 1.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '1.0.0')).toBe(true);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 1.0.1', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '1.0.1')).toBe(true);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 1.1.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '1.1.0')).toBe(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export function opensearchVersionCompatibleWithOpenSearchDashboards(
patch: semver.patch(opensearchDashboardsVersion),
};

if (
legacyVersionCompatibleWithOpenSearchDashboards(
opensearchVersionNumbers,
opensearchDashboardsVersionNumbers
)
) {
return true;
}

// Reject mismatching major version numbers.
if (opensearchVersionNumbers.major !== opensearchDashboardsVersionNumbers.major) {
return false;
Expand All @@ -78,3 +87,23 @@ export function opensearchVersionEqualsOpenSearchDashboards(
nodeSemVer.version === opensearchDashboardsSemver.version
);
}

/**
* Verify legacy version of engines is compatible with current version
* of OpenSearch Dashboards if OpenSearch Dashboards is 1.x.
*
* @param legacyVersionNumbers semantic version of legacy engine
* @param opensearchDashboardsVersionNumbers semantic version of application
* @returns {boolean}
*/
function legacyVersionCompatibleWithOpenSearchDashboards(
legacyVersionNumbers: any,
opensearchDashboardsVersionNumbers: any
) {
return (
legacyVersionNumbers.major === 7 &&
legacyVersionNumbers.minor === 10 &&
legacyVersionNumbers.patch === 2 &&
opensearchDashboardsVersionNumbers.major === 1
);
}

0 comments on commit e08432d

Please sign in to comment.