From bd9323e412c8effa2b417a7eb9027d28aa20fb51 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 16 Nov 2023 12:38:06 +1100 Subject: [PATCH 1/7] fix: use quote for test labels Signed-off-by: Lenin Mehedy --- .../fullstack-deployment/templates/_helpers.tpl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/charts/fullstack-deployment/templates/_helpers.tpl b/charts/fullstack-deployment/templates/_helpers.tpl index 6b039d8f0..f142bcc2a 100644 --- a/charts/fullstack-deployment/templates/_helpers.tpl +++ b/charts/fullstack-deployment/templates/_helpers.tpl @@ -1,11 +1,13 @@ {{- define "fullstack.testLabels" -}} -{{- if .Values.deployment.testMetadata.enabled }} -fullstack.hedera.com/testSuiteName: {{ .Values.deployment.testMetadata.testSuiteName }} -fullstack.hedera.com/testName: {{ .Values.deployment.testMetadata.testName }} -fullstack.hedera.com/testRunUID: {{ .Values.deployment.testMetadata.testRunUID }} -fullstack.hedera.com/testCreationTimestamp: {{ .Values.deployment.testMetadata.testCreationTimestamp }} -fullstack.hedera.com/testExpirationTimestamp: {{ .Values.deployment.testMetadata.testExpirationTimestamp }} -fullstack.hedera.com/testRequester: {{ .Values.deployment.testMetadata.testRequester }} +{{- if .Values.deployment.testMetadata.enabled -}} +{{- with .Values.deployment.testMetadata -}} +fullstack.hedera.com/testSuiteName: "{{ .testSuiteName }}" +fullstack.hedera.com/testName: "{{ .testName }}" +fullstack.hedera.com/testRunUID: "{{ .testRunUID }}" +fullstack.hedera.com/testCreationTimestamp: "{{ .testCreationTimestamp }}" +fullstack.hedera.com/testExpirationTimestamp: "{{ .testExpirationTimestamp }}" +fullstack.hedera.com/testRequester: "{{ .testRequester }}" +{{- end }} {{- end }} {{- end }} From 6a31048c09e39365137e368fc217fa0e455c76c1 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Fri, 17 Nov 2023 10:04:52 +1100 Subject: [PATCH 2/7] ci: setup node before running test-e2e Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 5d9f5908b..bdea0a05c 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -163,6 +163,9 @@ jobs: fsnetman cluster create fsnetman cluster setup fsnetman chart install + ls -la ~/.fsnetman/cache/v0.42 + fsnetman node setup -t v0.42.5 + ls -la ~/.fsnetman/cache/v0.42 npm run test-e2e # This step tests the Helm chart direct mode of operation which uses the ubi8-init-java17 image. From 49160cddf897fce1979ea5f6d8fa85de8c310e1e Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Fri, 17 Nov 2023 10:18:29 +1100 Subject: [PATCH 3/7] test: use test-cache-dir to reduce reduce duplicate package download execution test Signed-off-by: Lenin Mehedy --- .../e2e/core/package_downloader_e2e.test.mjs | 15 ++++---- .../e2e/core/platform_installer_e2e.test.mjs | 35 +++++++++++++------ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs index ce41e10ed..e11384f2a 100644 --- a/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs @@ -1,25 +1,22 @@ -import { describe, expect, it } from '@jest/globals' +import {describe, expect, it} from '@jest/globals' import * as fs from 'fs' import * as path from 'path' import * as os from 'os' -import { logging, PackageDownloader, Templates } from '../../../src/core/index.mjs' +import {logging, PackageDownloader, Templates} from '../../../src/core/index.mjs' describe('PackageDownloaderE2E', () => { const testLogger = logging.NewLogger('debug') const downloader = new PackageDownloader(testLogger) it('should succeed with a valid Hedera release tag', async () => { - const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'downloader-')) + const testCacheDir = 'test/data/tmp' const tag = 'v0.42.5' const releasePrefix = Templates.prepareReleasePrefix(tag) - const destPath = `${tmpDir}/${releasePrefix}/build-${tag}.zip` - await expect(downloader.fetchPlatform(tag, tmpDir)).resolves.toBe(destPath) + const destPath = `${testCacheDir}/${releasePrefix}/build-${tag}.zip` + await expect(downloader.fetchPlatform(tag, testCacheDir)).resolves.toBe(destPath) expect(fs.existsSync(destPath)).toBeTruthy() testLogger.showUser(destPath) - - // remove the downloaded files to reduce disk usage - fs.rmSync(`${tmpDir}`, { recursive: true }) - }, 100000) + }, 200000) }) diff --git a/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs index 8f047f715..eebb7411d 100644 --- a/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs @@ -1,5 +1,5 @@ -import { describe, expect, it } from '@jest/globals' -import { PackageDownloader, PlatformInstaller, constants, logging, Kubectl } from '../../../src/core/index.mjs' +import {beforeAll, describe, expect, it} from '@jest/globals' +import {PackageDownloader, PlatformInstaller, constants, logging, Kubectl, Templates} from '../../../src/core/index.mjs' import * as fs from 'fs' import * as path from 'path' import * as os from 'os' @@ -9,10 +9,17 @@ describe('PackageInstallerE2E', () => { const kubectl = new Kubectl(testLogger) const installer = new PlatformInstaller(testLogger, kubectl) const downloader = new PackageDownloader(testLogger) + const testCacheDir = 'test/data/tmp' const podName = 'network-node0-0' const packageTag = 'v0.42.5' let packageFile = '' + beforeAll(() => { + if (!fs.existsSync(testCacheDir)) { + fs.mkdirSync(testCacheDir) + } + }) + describe('setupHapiDirectories', () => { it('should succeed with valid pod', async () => { expect.assertions(1) @@ -26,14 +33,20 @@ describe('PackageInstallerE2E', () => { }) describe('copyPlatform', () => { + it('should succeed fetching platform release', async () => { + const releasePrefix = Templates.prepareReleasePrefix(packageTag) + const destPath = `${testCacheDir}/${releasePrefix}/build-${packageTag}.zip` + await expect(downloader.fetchPlatform(packageTag, testCacheDir)).resolves.toBe(destPath) + expect(fs.existsSync(destPath)).toBeTruthy() + testLogger.showUser(destPath) + + // do not delete the cache dir + }, 200000) + it('should succeed with valid tag and pod', async () => { expect.assertions(1) try { - const tmpDir = 'test/data/tmp' - if (!fs.existsSync(tmpDir)) { - fs.mkdirSync(tmpDir) - } - packageFile = await downloader.fetchPlatform(packageTag, tmpDir) + packageFile = await downloader.fetchPlatform(packageTag, testCacheDir) await expect(installer.copyPlatform(podName, packageFile, true)).resolves.toBeTruthy() const outputs = await kubectl.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HAPI_PATH}`) testLogger.showUser(outputs) @@ -41,7 +54,7 @@ describe('PackageInstallerE2E', () => { console.error(e) expect(e).toBeNull() } - }, 20000) + }) }) describe('prepareConfigTxt', () => { @@ -69,7 +82,7 @@ describe('PackageInstallerE2E', () => { // verify file content matches expect(fileContents).toBe(configLines.join('\n')) - fs.rmSync(tmpDir, { recursive: true }) + fs.rmSync(tmpDir, {recursive: true}) }) }) @@ -88,7 +101,7 @@ describe('PackageInstallerE2E', () => { // verify copy of local-node data is at staging area expect(fs.existsSync(`${tmpDir}/templates`)).toBeTruthy() - fs.rmSync(tmpDir, { recursive: true }) + fs.rmSync(tmpDir, {recursive: true}) }) }) @@ -159,7 +172,7 @@ describe('PackageInstallerE2E', () => { expect(fileList).toContain(`${constants.HAPI_PATH}/data/config/api-permission.properties`) expect(fileList).toContain(`${constants.HAPI_PATH}/data/config/application.properties`) expect(fileList).toContain(`${constants.HAPI_PATH}/data/config/bootstrap.properties`) - fs.rmSync(tmpDir, { recursive: true }) + fs.rmSync(tmpDir, {recursive: true}) }, 10000) }) }) From ee33e617bcd1a1be69dd64eba5b9254cf5ed5af3 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Fri, 17 Nov 2023 10:28:36 +1100 Subject: [PATCH 4/7] ci: fix script Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index bdea0a05c..0fde1d914 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -163,7 +163,7 @@ jobs: fsnetman cluster create fsnetman cluster setup fsnetman chart install - ls -la ~/.fsnetman/cache/v0.42 + ls -la ~/.fsnetman/cache/v0.42 || true fsnetman node setup -t v0.42.5 ls -la ~/.fsnetman/cache/v0.42 npm run test-e2e From a5d44a3ce5dc7b5be3a1afc4a123c81c5eeb5966 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Fri, 17 Nov 2023 10:29:08 +1100 Subject: [PATCH 5/7] ci: no need to setup node for test-e2e Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 0fde1d914..5d9f5908b 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -163,9 +163,6 @@ jobs: fsnetman cluster create fsnetman cluster setup fsnetman chart install - ls -la ~/.fsnetman/cache/v0.42 || true - fsnetman node setup -t v0.42.5 - ls -la ~/.fsnetman/cache/v0.42 npm run test-e2e # This step tests the Helm chart direct mode of operation which uses the ubi8-init-java17 image. From efee8cd237ee168c924c992526cd04e3175b4c21 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Fri, 17 Nov 2023 10:46:30 +1100 Subject: [PATCH 6/7] test: allow higher timeout Signed-off-by: Lenin Mehedy --- .../test/e2e/core/platform_installer_e2e.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs index eebb7411d..890b264a1 100644 --- a/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs @@ -54,7 +54,7 @@ describe('PackageInstallerE2E', () => { console.error(e) expect(e).toBeNull() } - }) + }, 20000) }) describe('prepareConfigTxt', () => { From 3a0460647ca5ecb50f1860896ddc4f0a5e63fe84 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Fri, 17 Nov 2023 10:49:04 +1100 Subject: [PATCH 7/7] style: lint error fix Signed-off-by: Lenin Mehedy --- .../test/e2e/core/package_downloader_e2e.test.mjs | 6 ++---- .../test/e2e/core/platform_installer_e2e.test.mjs | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs index e11384f2a..56e012b66 100644 --- a/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/package_downloader_e2e.test.mjs @@ -1,8 +1,6 @@ -import {describe, expect, it} from '@jest/globals' +import { describe, expect, it } from '@jest/globals' import * as fs from 'fs' -import * as path from 'path' -import * as os from 'os' -import {logging, PackageDownloader, Templates} from '../../../src/core/index.mjs' +import { logging, PackageDownloader, Templates } from '../../../src/core/index.mjs' describe('PackageDownloaderE2E', () => { const testLogger = logging.NewLogger('debug') diff --git a/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs index 890b264a1..081cbbb31 100644 --- a/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/platform_installer_e2e.test.mjs @@ -1,5 +1,5 @@ -import {beforeAll, describe, expect, it} from '@jest/globals' -import {PackageDownloader, PlatformInstaller, constants, logging, Kubectl, Templates} from '../../../src/core/index.mjs' +import { beforeAll, describe, expect, it } from '@jest/globals' +import { PackageDownloader, PlatformInstaller, constants, logging, Kubectl, Templates } from '../../../src/core/index.mjs' import * as fs from 'fs' import * as path from 'path' import * as os from 'os' @@ -82,7 +82,7 @@ describe('PackageInstallerE2E', () => { // verify file content matches expect(fileContents).toBe(configLines.join('\n')) - fs.rmSync(tmpDir, {recursive: true}) + fs.rmSync(tmpDir, { recursive: true }) }) }) @@ -101,7 +101,7 @@ describe('PackageInstallerE2E', () => { // verify copy of local-node data is at staging area expect(fs.existsSync(`${tmpDir}/templates`)).toBeTruthy() - fs.rmSync(tmpDir, {recursive: true}) + fs.rmSync(tmpDir, { recursive: true }) }) }) @@ -172,7 +172,7 @@ describe('PackageInstallerE2E', () => { expect(fileList).toContain(`${constants.HAPI_PATH}/data/config/api-permission.properties`) expect(fileList).toContain(`${constants.HAPI_PATH}/data/config/application.properties`) expect(fileList).toContain(`${constants.HAPI_PATH}/data/config/bootstrap.properties`) - fs.rmSync(tmpDir, {recursive: true}) + fs.rmSync(tmpDir, { recursive: true }) }, 10000) }) })