Skip to content

Commit

Permalink
hack: getting the general idea worked out
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Mar 29, 2024
1 parent 584ae15 commit 60b7f9c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 9 deletions.
46 changes: 46 additions & 0 deletions test/bin/bacalhau-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

create_client() {
environment=$1

case "$environment" in
production)
echo "Running in production environment"
export BACALHAU_DIR=/home/frrist/workspace/src/github.com/bacalhau-project/bacalhau/test/clusters/production
;;
staging)
echo "Running in staging environment"
export BACALHAU_DIR=/home/frrist/workspace/src/github.com/bacalhau-project/bacalhau/test/clusters/staging
;;
development)
echo "Running in development environment"
export BACALHAU_DIR=/home/frrist/workspace/src/github.com/bacalhau-project/bacalhau/test/clusters/development
;;
local)
echo "Running in local environment"
export BACALHAU_DIR=/home/frrist/workspace/src/github.com/bacalhau-project/bacalhau/test/clusters/local
# uses an existing cluster, doesn't delete anything after test runs
;;
spawn)
echo "Spawning a new environment"
# TODO create a cluster and run the tests against that.
# spawn an emphermal cluster and tear it down when tests are complete
;;
*)
echo "Unknown environment: $environment"
;;
esac
}

before_all() {
ROOT=$(git rev-parse --show-toplevel)
BACALHAU_BINARY=$(find $ROOT/bin -name 'bacalhau')
BACALHAU=$BACALHAU_BINARY
export LOG_LEVEL=WARN
# export BACALHAU_NODE_SERVERAPI_HOST='localhost'
export PATH=$(dirname $BACALHAU_BINARY):$PATH
}

after_each() {
# TODO this function should remove everything from the repo execept the config file and token
clean_repo
}
6 changes: 6 additions & 0 deletions test/clusters/development/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Node:
Name: ""
NameProvider: puuid
ClientAPI:
Host: bootstrap.development.bacalhau.org
Port: 1234
6 changes: 6 additions & 0 deletions test/clusters/local/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Node:
Name: ""
NameProvider: puuid
ClientAPI:
Host: "0.0.0.0"
Port: 1234
6 changes: 6 additions & 0 deletions test/clusters/production/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Node:
Name: ""
NameProvider: puuid
ClientAPI:
Host: bootstrap.production.bacalhau.org
Port: 1234
6 changes: 6 additions & 0 deletions test/clusters/staging/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Node:
Name: ""
NameProvider: puuid
ClientAPI:
Host: bootstrap.staging.bacalhau.org
Port: 1234
7 changes: 2 additions & 5 deletions test/connect_to_external_cluster.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!bin/bashtub

source bin/bacalhau.sh
source bin/bacalhau-client.sh

testcase_can_run_docker_hello_world_external_cluster() {
export BACALHAU_NODE_CLIENTAPI_HOST=34.86.177.175
export BACALHAU_NODE_CLIENTAPI_PORT=1234
export BACALHAU_NODE_NETWORK_TYPE=nats
export BACALHAU_NODE_NETWORK_ORCHESTRATORS=35.245.221.171:4222
create_client "production"
bacalhau job run --follow $ROOT/testdata/jobs/docker-hello.yaml
subject bacalhau job run --follow $ROOT/testdata/jobs/docker-hello.yaml
assert_equal 0 $status
Expand Down
3 changes: 2 additions & 1 deletion test/get-job-logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ source bin/bacalhau.sh

testcase_can_get_logs() {
# Assuming create_node is a function that takes two arguments separated by space, not comma
create_node requester,compute
# create_node requester,compute
create_client "production"
job_id=$(bacalhau job run --id-only $ROOT/testdata/jobs/docker-hello.yaml)
subject bacalhau job logs $job_id
assert_equal 0 $status
Expand Down
5 changes: 2 additions & 3 deletions test/hello-world-docker-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
source bin/bacalhau.sh

testcase_can_run_docker_hello_world() {
# Assuming create_node is a function that takes two arguments separated by comma, not space
create_node requester,compute

# Assuming create_node is a function that takes two arguments separated by comma, not space
create_client "production"
subject bacalhau job run --follow $ROOT/testdata/jobs/docker-hello.yaml
assert_equal 0 $status
assert_match "Hello Bacalhau!" $(echo $stdout)
Expand Down

0 comments on commit 60b7f9c

Please sign in to comment.