From 60b7f9cc3a4c749cc433f88f395b4bccc4bf7451 Mon Sep 17 00:00:00 2001 From: frrist Date: Fri, 29 Mar 2024 12:18:46 -0700 Subject: [PATCH] hack: getting the general idea worked out --- test/bin/bacalhau-client.sh | 46 +++++++++++++++++++++++++++ test/clusters/development/config.yaml | 6 ++++ test/clusters/local/config.yaml | 6 ++++ test/clusters/production/config.yaml | 6 ++++ test/clusters/staging/config.yaml | 6 ++++ test/connect_to_external_cluster.sh | 7 ++-- test/get-job-logs.sh | 3 +- test/hello-world-docker-v2.sh | 5 ++- 8 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 test/bin/bacalhau-client.sh create mode 100644 test/clusters/development/config.yaml create mode 100644 test/clusters/local/config.yaml create mode 100644 test/clusters/production/config.yaml create mode 100644 test/clusters/staging/config.yaml diff --git a/test/bin/bacalhau-client.sh b/test/bin/bacalhau-client.sh new file mode 100644 index 0000000000..ba4c00c84d --- /dev/null +++ b/test/bin/bacalhau-client.sh @@ -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 +} diff --git a/test/clusters/development/config.yaml b/test/clusters/development/config.yaml new file mode 100644 index 0000000000..76fc52bdd6 --- /dev/null +++ b/test/clusters/development/config.yaml @@ -0,0 +1,6 @@ +Node: + Name: "" + NameProvider: puuid + ClientAPI: + Host: bootstrap.development.bacalhau.org + Port: 1234 diff --git a/test/clusters/local/config.yaml b/test/clusters/local/config.yaml new file mode 100644 index 0000000000..a779b290c3 --- /dev/null +++ b/test/clusters/local/config.yaml @@ -0,0 +1,6 @@ +Node: + Name: "" + NameProvider: puuid + ClientAPI: + Host: "0.0.0.0" + Port: 1234 diff --git a/test/clusters/production/config.yaml b/test/clusters/production/config.yaml new file mode 100644 index 0000000000..3d9133cc8e --- /dev/null +++ b/test/clusters/production/config.yaml @@ -0,0 +1,6 @@ +Node: + Name: "" + NameProvider: puuid + ClientAPI: + Host: bootstrap.production.bacalhau.org + Port: 1234 diff --git a/test/clusters/staging/config.yaml b/test/clusters/staging/config.yaml new file mode 100644 index 0000000000..4da91fb696 --- /dev/null +++ b/test/clusters/staging/config.yaml @@ -0,0 +1,6 @@ +Node: + Name: "" + NameProvider: puuid + ClientAPI: + Host: bootstrap.staging.bacalhau.org + Port: 1234 diff --git a/test/connect_to_external_cluster.sh b/test/connect_to_external_cluster.sh index 6215ed7661..18b331da45 100644 --- a/test/connect_to_external_cluster.sh +++ b/test/connect_to_external_cluster.sh @@ -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 diff --git a/test/get-job-logs.sh b/test/get-job-logs.sh index 224dff6c9d..2ab019f83c 100644 --- a/test/get-job-logs.sh +++ b/test/get-job-logs.sh @@ -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 diff --git a/test/hello-world-docker-v2.sh b/test/hello-world-docker-v2.sh index 32badaeda9..f61573c915 100644 --- a/test/hello-world-docker-v2.sh +++ b/test/hello-world-docker-v2.sh @@ -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)