-
Notifications
You must be signed in to change notification settings - Fork 6
Fix/ Add free compute system tests #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bogdanfazakas
wants to merge
38
commits into
main
Choose a base branch
from
fix/system-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+421
−233
Open
Changes from 4 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e78c981
add compute test file
bogdanfazakas 4e42d6a
merge release v4.0
bogdanfazakas edfcc35
update compute commands
bogdanfazakas d96c841
update key
bogdanfazakas 43875bd
merge fixes
bogdanfazakas 238216c
small fixes
bogdanfazakas b99f35d
merge
bogdanfazakas 261b489
add log
bogdanfazakas 8ada08f
merge main
bogdanfazakas 8035089
check ocean node issue
bogdanfazakas 73424dc
try legacy peers
bogdanfazakas 8bdc712
update node version
bogdanfazakas 1c11caf
update get env test
bogdanfazakas 55c7860
upgrade typescript-eslint
bogdanfazakas c6055b3
revert changes
bogdanfazakas 569a1e6
update compute test
bogdanfazakas 8770d2a
update check
bogdanfazakas f98519a
put back main
bogdanfazakas e7d4474
update regular expression pattern
bogdanfazakas 757c3ff
final touch
bogdanfazakas 10c91ee
cleanup
bogdanfazakas 49e9e0a
merge main
bogdanfazakas 1d8870f
merge main and fix conflicts
bogdanfazakas 01b6c1a
add get results
bogdanfazakas 98c1e0c
update wait job to finish test
bogdanfazakas f8c9320
update regex
bogdanfazakas 25ca7ac
debug logs
bogdanfazakas 65a55a3
debug logs
bogdanfazakas 19f336b
update regex
bogdanfazakas 341d235
update parse logic
bogdanfazakas 33547eb
more enhacemnts
bogdanfazakas 9c58977
use strip ansi
bogdanfazakas 415d452
more regex
bogdanfazakas 9059b1e
debug
bogdanfazakas ed940f4
cleanup
bogdanfazakas b46ba69
print ocean logs
bogdanfazakas 9b7ecec
use node branch from barge
bogdanfazakas 020c9bf
add more logs and details
bogdanfazakas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import { expect } from "chai"; | ||
| import { exec } from "child_process"; | ||
| import path from "path"; | ||
| import fs from "fs"; | ||
| import util from "util"; | ||
|
|
||
| const execPromise = util.promisify(exec); | ||
|
|
||
| describe("Ocean CLI Free Compute Flow", function () { | ||
| this.timeout(300000); | ||
|
|
||
| const projectRoot = path.resolve(__dirname, ".."); | ||
|
|
||
| let computeDatasetDid: string; | ||
| let algoDid: string; | ||
| let computeEnvId: string; | ||
| let jobId: string; | ||
|
|
||
| const runCommand = async (command: string): Promise<string> => { | ||
| console.log(`\n[CMD]: ${command}`); | ||
| try { | ||
| const { stdout } = await execPromise(command, { cwd: projectRoot }); | ||
| console.log(`[OUTPUT]:\n${stdout}`); | ||
| return stdout; | ||
| } catch (error: any) { | ||
| console.error(`[ERROR]:\n${error.stderr || error.message}`); | ||
| throw error; | ||
| } | ||
| }; | ||
|
|
||
| before(async () => { | ||
| process.env.PRIVATE_KEY = | ||
| "0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699b1150a5befc"; | ||
| process.env.RPC = "http://127.0.0.1:8545"; | ||
| process.env.AQUARIUS_URL = "http://127.0.0.1:5000"; | ||
bogdanfazakas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| process.env.PROVIDER_URL = "http://127.0.0.1:8030"; | ||
| }); | ||
|
|
||
| it("should publish a compute dataset", async () => { | ||
| const metadataFile = path.resolve( | ||
| projectRoot, | ||
| "metadata/simpleComputeDataset.json" | ||
| ); | ||
|
|
||
| if (!fs.existsSync(metadataFile)) { | ||
| throw new Error(`Metadata file not found: ${metadataFile}`); | ||
| } | ||
|
|
||
| const output = await runCommand(`npm run cli publish ${metadataFile}`); | ||
|
|
||
| const didMatch = output.match(/did:op:[a-f0-9]{64}/); | ||
| expect(didMatch, "No DID found in output").to.not.be.null; | ||
|
|
||
| computeDatasetDid = didMatch![0]; | ||
| console.log(`Published Compute Dataset DID: ${computeDatasetDid}`); | ||
| }); | ||
|
|
||
| it("should publish an algorithm", async () => { | ||
| const algoFile = path.resolve(projectRoot, "metadata/jsAlgo.json"); | ||
|
|
||
| if (!fs.existsSync(algoFile)) { | ||
| throw new Error(`Algorithm metadata file not found: ${algoFile}`); | ||
| } | ||
|
|
||
| const output = await runCommand(`npm run cli publishAlgo ${algoFile}`); | ||
|
|
||
| const didMatch = output.match(/did:op:[a-f0-9]{64}/); | ||
| expect(didMatch, "No DID found in output").to.not.be.null; | ||
|
|
||
| algoDid = didMatch![0]; | ||
| console.log(`Published Algorithm DID: ${algoDid}`); | ||
| }); | ||
|
|
||
| it("should get compute environments", async () => { | ||
| const output = await runCommand(`npm run cli getComputeEnvironments`); | ||
|
|
||
| expect(output).to.contain("id"); | ||
|
|
||
| const envMatch = output.match(/id: (0x[a-fA-F0-9]+)/); | ||
bogdanfazakas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!envMatch) | ||
| throw new Error("No environment ID found in environments output"); | ||
|
|
||
| computeEnvId = envMatch[1]; | ||
| console.log(`Fetched Compute Env ID: ${computeEnvId}`); | ||
| }); | ||
|
|
||
| it("should start a free compute job", async () => { | ||
| const output = await runCommand( | ||
paulo-ocean marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `npm run cli startFreeCompute -- --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` | ||
| ); | ||
|
|
||
| const jobIdMatch = output.match( | ||
| /Job started successfully with ID: ([a-f0-9-]+)/i | ||
| ); | ||
| expect(jobIdMatch, "No Job ID found in output").to.not.be.null; | ||
|
|
||
| jobId = jobIdMatch![1]; | ||
| console.log(`Started Free Compute Job ID: ${jobId}`); | ||
| }); | ||
|
|
||
| it("should get job status", async () => { | ||
| const output = await runCommand( | ||
| `npm run cli getJobStatus -- --dataset ${computeDatasetDid} --job ${jobId}` | ||
| ); | ||
|
|
||
| expect(output).to.contain(jobId); | ||
| expect(output.toLowerCase()).to.match(/status/); | ||
| console.log(`Job status retrieved for jobId: ${jobId}`); | ||
| }); | ||
|
|
||
| it("should fetch streamable logs", async () => { | ||
| const output = await runCommand( | ||
| `npm run cli computeStreamableLogs -- --job ${jobId}` | ||
| ); | ||
|
|
||
| expect(output).to.contain(jobId); | ||
| console.log(`Streamable logs retrieved for jobId: ${jobId}`); | ||
| }); | ||
|
|
||
| it("should stop the compute job", async () => { | ||
| const output = await runCommand( | ||
| `npm run cli stopCompute -- --dataset ${computeDatasetDid} --job ${jobId}` | ||
bogdanfazakas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| expect(output).to.contain("Compute job stopped successfully"); | ||
| console.log(`Stopped compute job with ID: ${jobId}`); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.