diff --git a/.github/workflows/testK8sOnly.yml b/.github/workflows/testK8sOnly.yml deleted file mode 100644 index f5c0ceb5aa4..00000000000 --- a/.github/workflows/testK8sOnly.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Teraslice CI Tests K8sOnly -# this will technically run again on merge to master, should limit it -on: - pull_request: - branches: [ master ] - -jobs: - e2e-k8s-tests: - runs-on: ubuntu-latest - strategy: - # opensearch is finiky, keep testing others if it fails - fail-fast: false - matrix: - node-version: [16.19.1, 18.16.0] - steps: - - name: Check out code - uses: actions/checkout@v3 - - - name: Setup Node ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'yarn' - - # we login to docker to avoid docker pull limit rates - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Install and build packages - run: yarn setup - env: - YARN_SETUP_ARGS: "--prod=false --silent" - - - name: Install Kind and Kubectl - uses: helm/kind-action@v1.8.0 - with: - install_only: "true" - - - name: Test k8s elasticsearch7 - run: yarn --silent test:k8s --node-version ${{ matrix.node-version }} - working-directory: ./e2e diff --git a/e2e/package.json b/e2e/package.json index f832c0e7825..91565c7e313 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -28,8 +28,8 @@ "test:debug": "TEST_ELASTICSEARCH='true' TEST_KAFKA='true' ts-scripts test --suite e2e --debug --", "test:elasticsearch6": "TEST_ELASTICSEARCH='true' TEST_KAFKA='true' ts-scripts test --suite e2e --", "test:elasticsearch7": "TEST_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' TEST_KAFKA='true' ts-scripts test --suite e2e --", - "test:k8s": "TEST_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' KAFKA_VERSION='3.1' TEST_KAFKA='true' TEST_PLATFORM='kubernetes' DEBUG='*' ts-scripts test --suite e2e --debug --", - "test:k8sNoBuild": "SKIP_DOCKER_BUILD_IN_E2E='true' TEST_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' KAFKA_VERSION='3.1' TEST_KAFKA='true' TEST_PLATFORM='kubernetes' DEBUG='*' ts-scripts test --suite e2e --debug -- --silent=false", + "test:k8s": "TEST_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' KAFKA_VERSION='3.1' TEST_KAFKA='true' TEST_PLATFORM='kubernetes' ts-scripts test --suite e2e --", + "test:k8sNoBuild": "SKIP_DOCKER_BUILD_IN_E2E='true' TEST_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' KAFKA_VERSION='3.1' TEST_KAFKA='true' TEST_PLATFORM='kubernetes' ts-scripts test --suite e2e --", "test:opensearch1": "TEST_OPENSEARCH='true' TEST_KAFKA='true' ts-scripts test --suite e2e --", "test:opensearch2": "TEST_OPENSEARCH='true' OPENSEARCH_VERSION='2.8.0' TEST_KAFKA='true' ts-scripts test --suite e2e --", "test:watch": "TEST_ELASTICSEARCH='true' TEST_KAFKA='true' ts-scripts test --suite e2e --watch --" diff --git a/e2e/test/global.setup.js b/e2e/test/global.setup.js index 0d052e3fb5d..7c0512ff716 100644 --- a/e2e/test/global.setup.js +++ b/e2e/test/global.setup.js @@ -17,7 +17,6 @@ const { } = require('./config'); module.exports = async () => { - signale.debug('@@@@ HOST_IP: ', HOST_IP); const teraslice = new TerasliceHarness(); await teraslice.init(); diff --git a/e2e/test/global.teardown.js b/e2e/test/global.teardown.js index 38dfa656e31..b4a7e2563dd 100644 --- a/e2e/test/global.teardown.js +++ b/e2e/test/global.teardown.js @@ -26,7 +26,7 @@ async function globalTeardown(testClient) { const errors = []; try { - if (TEST_PLATFORM === 'kubernetes' && !process.env.KEEP_OPEN) { + if (TEST_PLATFORM === 'kubernetes') { await deleteTerasliceNamespace(); await cleanupIndex(client, 'ts-dev1_*'); } else { diff --git a/e2e/test/teraslice-harness.js b/e2e/test/teraslice-harness.js index db7a8fa6c5e..95fe62a470c 100644 --- a/e2e/test/teraslice-harness.js +++ b/e2e/test/teraslice-harness.js @@ -6,8 +6,7 @@ const { cloneDeep, isEmpty, castArray } = require('@terascope/utils'); const { - deployK8sTeraslice, showState, showTSMasterLogs, - showTSExLogs, showTSWorkerLogs, describeWorker, getPodYamls, describeNode + deployK8sTeraslice, showState } = require('@terascope/scripts'); const { createClient, ElasticsearchTestHelpers } = require('elasticsearch-store'); const { TerasliceClient } = require('teraslice-client-js'); @@ -60,13 +59,6 @@ module.exports = class TerasliceHarness { const start = Date.now(); try { - if (process.env.TEST_PLATFORM === 'kubernetes') { - signale.debug('@@@ before ex.waitForExStatus'); - signale.debug(await showState(HOST_IP)); - signale.debug(await describeWorker()); - signale.debug(await describeNode()); - signale.debug(await getPodYamls()); - } const result = await ex.waitForStatus(status, interval, 2 * 60 * 1000); if (endDelay) { // since most of the time we are chaining this with other actions @@ -74,25 +66,8 @@ module.exports = class TerasliceHarness { // it a little bit of time await pDelay(endDelay); } - if (process.env.TEST_PLATFORM === 'kubernetes') { - signale.debug('@@@ after ex.waitForExStatus'); - signale.debug(await showState(HOST_IP)); - signale.debug(await describeWorker()); - signale.debug(await describeNode()); - signale.debug(await getPodYamls()); - } return result; } catch (err) { - if (process.env.TEST_PLATFORM === 'kubernetes') { - signale.debug('@@@ in catch of waitForExStatus'); - signale.debug(await describeWorker()); - signale.debug(await describeNode()); - signale.debug(await getPodYamls()); - signale.debug(await showState(HOST_IP)); - signale.debug(await showTSMasterLogs()); - signale.debug(await showTSExLogs()); - signale.debug(await showTSWorkerLogs()); - } err.message = `Execution: ${ex.id()}: ${err.message}`; this.warn(err.stack, { @@ -116,12 +91,11 @@ module.exports = class TerasliceHarness { if (TEST_PLATFORM === 'kubernetes') { try { - // console.log('@@@@ before state reset'); // await showState(HOST_IP); await cleanupIndex(this.client, `${SPEC_INDEX_PREFIX}*`); await this.clearNonBaseAssets(); } catch (err) { - signale.error('Failure to clean indices', err); + signale.error('Failure to clean indices and assets', err); throw err; } try { @@ -129,7 +103,6 @@ module.exports = class TerasliceHarness { await pDelay(2000); await this.waitForTeraslice(); await pDelay(2000); - // console.log('@@@@ after state reset'); await showState(HOST_IP); } catch (err) { signale.error('Failure to reset teraslice state', err); @@ -459,13 +432,7 @@ module.exports = class TerasliceHarness { } async postJob(jobSpec) { - const result = this.teraslice.executions.submit(jobSpec); - signale.debug('@@@ postJob result: ', result); - if (process.env.TEST_PLATFORM === 'kubernetes') { - signale.debug('@@@ after postJob result'); - signale.debug(await showState(HOST_IP)); - } - return result; + return this.teraslice.executions.submit(jobSpec); } async generate(count, hex) { @@ -514,15 +481,7 @@ module.exports = class TerasliceHarness { await Promise.all(executions.map((ex) => this.waitForExStatus(ex, 'completed'))); } else { const ex = await this.postJob(jobSpec); - if (process.env.TEST_PLATFORM === 'kubernetes') { - signale.debug('@@@ after postJob'); - signale.debug(await showState(HOST_IP)); - } await this.waitForExStatus(ex, 'completed'); - if (process.env.TEST_PLATFORM === 'kubernetes') { - signale.debug('@@@ after waitForExStatus'); - signale.debug(await showState(HOST_IP)); - } } signale.info(`Generated ${indexName} example data`, getElapsed(genStartTime)); @@ -556,17 +515,12 @@ module.exports = class TerasliceHarness { async clearNonBaseAssets() { const assetList = await this.teraslice.assets.list(); - // console.log('@@@@@ assetList: ', assetList); - const baseAssets = ['standard', 'elasticsearch', 'kafka']; const assetsToDelete = assetList.filter((assetObj) => !baseAssets.includes(assetObj.name)); - // console.log('@@@@@ assetsToDelete: ', assetsToDelete); for (const asset of assetsToDelete) { - // console.log('@@@@@ asset: ', asset); const response = await this.teraslice.assets.remove(asset.id); - // console.log('@@@@@ response: ', response); - signale.success(`Deleted asset with id ${response}`); + signale.debug(`Deleted asset with id ${response._id}`); } } }; diff --git a/packages/scripts/src/helpers/scripts.ts b/packages/scripts/src/helpers/scripts.ts index 474479775d1..0a065973470 100644 --- a/packages/scripts/src/helpers/scripts.ts +++ b/packages/scripts/src/helpers/scripts.ts @@ -542,20 +542,17 @@ export async function createKindCluster(): Promise { const configPath = path.join(e2eK8sDir, 'kindConfig.yaml'); const subprocess = await execa.command(`kind create cluster --config ${configPath}`); - signale.debug(subprocess.stderr); logger.debug(subprocess.stderr); } export async function destroyKindCluster(): Promise { const subprocess = await execa.command('kind delete cluster --name k8se2e'); - signale.debug(subprocess.stderr); logger.debug(subprocess.stderr); } export async function isKindInstalled(): Promise { try { const subprocess = await execa.command('command -v kind'); - // console.log('kind subprocess: ', subprocess); return !!subprocess.stdout; } catch (err) { return false; @@ -565,7 +562,6 @@ export async function isKindInstalled(): Promise { export async function isKubectlInstalled(): Promise { try { const subprocess = await execa.command('command -v kubectl'); - // console.log('kubectl subprocess: ', subprocess); return !!subprocess.stdout; } catch (err) { return false; @@ -575,8 +571,6 @@ export async function isKubectlInstalled(): Promise { // TODO: check that image is loaded before we continue export async function loadTerasliceImage(terasliceImage: string): Promise { const subprocess = await execa.command(`kind load docker-image ${terasliceImage} --name k8se2e`); - // console.log('load teraslice image subprocess: ', subprocess); - signale.debug(subprocess.stderr); logger.debug(subprocess.stderr); } @@ -590,9 +584,7 @@ export async function kindStopService(serviceName: string): Promise { // Any new service's yaml file must be named 'Deployment.yaml' const yamlFile = `${serviceName}Deployment.yaml`; const subprocess = await execa.command(`kubectl delete -n services-dev1 -f ${path.join(e2eK8sDir, yamlFile)}`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - // console.log('stopElasticsearch subprocess: ', subprocess); } catch (err) { // Do nothing. This should fail because no services should be up yet. } @@ -605,11 +597,8 @@ export async function kindLoadServiceImage( ): Promise { try { const subprocess = await execa.command(`kind load docker-image ${serviceImage}:${version} --name k8se2e`); - // console.log('load service image subprocess: ', subprocess); - signale.debug(subprocess.stderr); logger.debug(subprocess.stderr); } catch (err) { - signale.debug(`The service ${serviceName} could not be loaded. It may not be present locally`); logger.debug(`The service ${serviceName} could not be loaded. It may not be present locally`); } } @@ -625,10 +614,8 @@ export async function kindStartService(serviceName: string): Promise { try { const subprocess = await execa.command(`kubectl create -n services-dev1 -f ${path.join(e2eK8sDir, yamlFile)}`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); } catch (err) { - signale.error(`The service ${serviceName} could not be started: `, err); logger.error(`The service ${serviceName} could not be started: `, err); } @@ -649,7 +636,6 @@ function waitForKafkaRunning(timeoutMs = 120000): Promise { try { const kubectlResponse = await execa.command('kubectl -n services-dev1 get pods -l app.kubernetes.io/name=cpkafka -o=jsonpath="{.items[?(@.status.containerStatuses)].status.containerStatuses[0].ready}"'); const kafkaReady = kubectlResponse.stdout; - // console.log('kafka response: ', kafkaReady); if (kafkaReady === '"true"') { kafkaRunning = true; } @@ -674,9 +660,7 @@ export async function createNamespace(namespaceYaml: string) { throw new Error('Missing k8s e2e test directory'); } const subprocess = await execa.command(`kubectl create -f ${path.join(e2eK8sDir, namespaceYaml)}`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - // console.log('namespace subprocess: ', subprocess); } export async function k8sSetup(): Promise { @@ -686,13 +670,10 @@ export async function k8sSetup(): Promise { } let subprocess = await execa.command(`kubectl create -f ${path.join(e2eK8sDir, 'role.yaml')}`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); subprocess = await execa.command(`kubectl create -f ${path.join(e2eK8sDir, 'roleBinding.yaml')}`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); subprocess = await execa.command(`kubectl apply -f ${path.join(e2eK8sDir, 'priorityClass.yaml')}`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); } @@ -708,24 +689,16 @@ export async function deployK8sTeraslice() { try { /// Creates configmap for terasclice-master let subprocess = await execa.command(`kubectl create -n ts-dev1 configmap teraslice-master --from-file=${path.join(e2eK8sDir, 'masterConfig', 'teraslice.yaml')}`); - // console.log('masterConfig subprocess: ', subprocess); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); /// Creates configmap for teraslice-worker subprocess = await execa.command(`kubectl create -n ts-dev1 configmap teraslice-worker --from-file=${path.join(e2eK8sDir, 'workerConfig', 'teraslice.yaml')}`); - // console.log('workerConfig subprocess: ', subprocess); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); /// Creates deployment for teraslice subprocess = await execa.command(`kubectl create -n ts-dev1 -f ${path.join(e2eK8sDir, 'masterDeployment.yaml')}`); - // console.log('masterDeploy subprocess: ', subprocess); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); } catch (err) { - signale.error('Error deploying Teraslice'); - signale.error(err); logger.error('Error deploying Teraslice'); logger.error(err); process.exit(1); @@ -741,28 +714,21 @@ export async function setAliasAndBaseAssets(hostIP: string) { async function setAlias(hostIP: string) { let subprocess = await execa.command('earl aliases remove k8se2e 2> /dev/null || true', { shell: true }); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); subprocess = await execa.command(`earl aliases add k8se2e http://${hostIP}:45678`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - // console.log('setAlias subprocess: ', subprocess1, subprocess2); } async function deployAssets(assetName: string) { const subprocess = await execa.command(`earl assets deploy k8se2e --blocking terascope/${assetName}-assets`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - // console.log('deployKafkaAssets subprocess: ', subprocess); } export async function deleteTerasliceNamespace() { try { const subprocess = await execa.command('kubectl delete namespace ts-dev1'); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); } catch (err) { - signale.debug('Teraslice namespace cannot be deleted because it does not exist'); logger.debug('Teraslice namespace cannot be deleted because it does not exist'); } } @@ -770,82 +736,21 @@ export async function deleteTerasliceNamespace() { // FIXME: delete before merging? - for testing export async function showState(hostIP: string) { const subprocess = await execa.command('kubectl get deployments,po,svc --all-namespaces --show-labels -o wide'); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - // console.log('\nshowState subprocess: \n', subprocess.stdout); await showESIndices(hostIP); await showAssets(hostIP); } async function showESIndices(hostIP: string) { const subprocess = await execa.command(`curl ${hostIP}:49200/_cat/indices`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - // console.log('\nshowESIndices subprocess: \n', subprocess.stdout); -} - -export async function showESData(hostIP: string) { - let subprocess = await execa.command(`curl ${hostIP}:49200/ts-dev1__ex/_search`); - signale.debug(subprocess.stdout); - logger.debug(subprocess.stdout); - subprocess = await execa.command(`curl ${hostIP}:49200/ts-dev1__analytics-2023.11/_search`); - signale.debug(subprocess.stdout); - logger.debug(subprocess.stdout); - subprocess = await execa.command(`curl ${hostIP}:49200/ts-dev1__state-2023.11/_search`); - signale.debug(subprocess.stdout); - logger.debug(subprocess.stdout); - // console.log('\nshowESIndices subprocess: \n', subprocess.stdout); -} - -export async function showTSMasterLogs() { - const subprocess = await execa.command('kubectl -n ts-dev1 logs --tail 1000 -l app.kubernetes.io/component=master'); - signale.debug(subprocess.stdout); - logger.debug(subprocess.stdout); -} - -export async function showTSExLogs() { - const subprocess = await execa.command('kubectl -n ts-dev1 logs --tail 1000 -l app.kubernetes.io/component=execution_controller'); - signale.debug(subprocess.stdout); - logger.debug(subprocess.stdout); -} - -export async function showTSWorkerLogs() { - const subprocess = await execa.command('kubectl -n ts-dev1 logs --tail 1000 -l app.kubernetes.io/component=worker'); - signale.debug(subprocess.stdout); - logger.debug(subprocess.stdout); -} - -export async function describeWorker() { - signale.debug('@@@ describeWorker'); - const subprocess = await execa.command('kubectl -n ts-dev1 describe pod -l app.kubernetes.io/component=worker'); - signale.debug(subprocess); - logger.debug(subprocess); -} - -export async function describeNode() { - signale.debug('@@@ describeNode'); - const subprocess = await execa.command('kubectl -n ts-dev1 describe node'); - signale.debug(subprocess); - logger.debug(subprocess); -} - -export async function getPodYamls() { - signale.debug('@@@ getPodYamls'); - const subprocess = await execa.command('kubectl -n ts-dev1 get pods -l app.kubernetes.io/component=worker -o yaml'); - signale.debug(subprocess); - logger.debug(subprocess); } async function showAssets(hostIP: string) { try { const subprocess = await execa.command(`curl ${hostIP}:45678/v1/assets`); - signale.debug(subprocess.stdout); logger.debug(subprocess.stdout); - - // console.log('\nshowAssets subprocess: \n', subprocess.stdout); } catch (err) { - signale.debug(err); logger.debug(err); - // console.log('\nshowAssets subprocess: \n', err); } } diff --git a/packages/scripts/src/helpers/test-runner/index.ts b/packages/scripts/src/helpers/test-runner/index.ts index 99051902ba0..b5c32831b00 100644 --- a/packages/scripts/src/helpers/test-runner/index.ts +++ b/packages/scripts/src/helpers/test-runner/index.ts @@ -199,7 +199,6 @@ async function runTestSuite( async function runE2ETest( options: TestOptions, tracker: TestTracker ): Promise { - // console.log('@@@@@@@@ options: ', options); tracker.expected++; const suite = 'e2e'; diff --git a/packages/scripts/src/helpers/test-runner/services.ts b/packages/scripts/src/helpers/test-runner/services.ts index 9f4458fe2ca..6c2b13490c2 100644 --- a/packages/scripts/src/helpers/test-runner/services.ts +++ b/packages/scripts/src/helpers/test-runner/services.ts @@ -752,7 +752,6 @@ async function startService(options: TestOptions, service: Service): Promise<() await stopService(service); - // console.log(`@@@@@@@ loading ${service} via docker`); const fn = await dockerRun( services[service], version,