Skip to content

Commit

Permalink
test: add dynamodb to test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 14, 2024
1 parent 9a6bea6 commit f9ec220
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/indexer/indexer_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = BeforeSuite(func() {
testConfig.Deployers[0].DeploySubgraphs = false

if testConfig.Environment.IsLocal() {
fmt.Println("Starting anvil")
fmt.Println("Starting anvil core indexer indexer_suite_test")
testConfig.StartAnvil()

fmt.Println("Deploying experiment")
Expand Down
2 changes: 1 addition & 1 deletion core/thegraph/state_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func setup() {
testConfig = deploy.NewTestConfig(testName, rootPath)
testConfig.Deployers[0].DeploySubgraphs = true

fmt.Println("Starting anvil")
fmt.Println("Starting anvil ---------- core thegraph state_integration_test")
testConfig.StartAnvil()

fmt.Println("Starting graph node")
Expand Down
2 changes: 1 addition & 1 deletion inabox/bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function stop_detached {

function start_anvil {

echo "Starting anvil server ....."
echo "Starting anvil server .... inabox bin.sh."
anvil --host 0.0.0.0 > /dev/null &
anvil_pid=$!
echo "Anvil server started ....."
Expand Down
65 changes: 64 additions & 1 deletion inabox/deploy/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,21 @@ func DeployResources(
return err
}

fmt.Println("Creating payment related tables")
fmt.Println("Creating payment related tables ---- in localstack")
// create payment related tables
err = meterer.CreateReservationTable(cfg, v2MetadataTableName+"_reservation")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateOnDemandTable(cfg, v2MetadataTableName+"_ondemand")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateGlobalReservationTable(cfg, v2MetadataTableName+"_global_reservation")
if err != nil {
fmt.Println("err", err)
return err
}
}
Expand All @@ -163,6 +166,66 @@ func DeployResources(

}

func DeployPaymentRelatedTables(
pool *dockertest.Pool,
localStackPort string,
) error {

if pool == nil {
var err error
pool, err = dockertest.NewPool("")
if err != nil {
fmt.Println("Could not construct pool: %w", err)
return err
}
}

// exponential backoff-retry, because the application in
// the container might not be ready to accept connections yet
pool.MaxWait = 10 * time.Second
_, b, _, _ := runtime.Caller(0)
rootPath := filepath.Join(filepath.Dir(b), "../..")
changeDirectory(filepath.Join(rootPath, "inabox"))
if err := pool.Retry(func() error {
fmt.Println("Creating S3 bucket")
return execCmd("./create-s3-bucket.sh", []string{}, []string{fmt.Sprintf("AWS_URL=http://0.0.0.0:%s", localStackPort)})
}); err != nil {
fmt.Println("Might be connected already:", err)
// return err
}

cfg := aws.ClientConfig{
Region: "us-east-1",
AccessKey: "localstack",
SecretAccessKey: "localstack",
EndpointURL: fmt.Sprintf("http://0.0.0.0:%s", localStackPort),
}

fmt.Println("Creating v2 tables deploy hleper")

v2TableName := "test_v2"
fmt.Println("Creating payment related tables")
// create payment related tables
err := meterer.CreateReservationTable(cfg, v2TableName+"_reservation")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateOnDemandTable(cfg, v2TableName+"_ondemand")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateGlobalReservationTable(cfg, v2TableName+"_global_reservation")
if err != nil {
fmt.Println("err", err)
return err
}

return err

}

func PurgeDockertestResources(pool *dockertest.Pool, resource *dockertest.Resource) {
fmt.Println("Stopping Dockertest resources")
if resource != nil {
Expand Down
17 changes: 11 additions & 6 deletions inabox/tests/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,28 @@ var _ = BeforeSuite(func() {
}
}

fmt.Println("Starting localstack!!!!!!!!!!!!!!!!!!!!!!!!!!!")

localStackPort = "4570"
pool, resource, err := deploy.StartDockertestWithLocalstackContainer(localStackPort)
Expect(err).To(BeNil())
dockertestPool = pool
dockertestResource = resource
testConfig = deploy.NewTestConfig(testName, rootPath)
if testConfig.Environment.IsLocal() {
if !inMemoryBlobStore {
fmt.Println("Using shared Blob Store")
localStackPort = "4570"
pool, resource, err := deploy.StartDockertestWithLocalstackContainer(localStackPort)
Expect(err).To(BeNil())
dockertestPool = pool
dockertestResource = resource

err = deploy.DeployResources(pool, localStackPort, metadataTableName, bucketTableName, metadataTableNameV2)
Expect(err).To(BeNil())
} else {
fmt.Println("Using in-memory Blob Store")
}
fmt.Println("Making payment related tables....")
err = deploy.DeployPaymentRelatedTables(pool, localStackPort)
Expect(err).To(BeNil())

fmt.Println("Starting anvil")
fmt.Println("Starting anvil inabox/tests/integration_suite_test.go")
testConfig.StartAnvil()

if deployer, ok := testConfig.GetDeployer(testConfig.EigenDA.Deployer); ok && deployer.DeploySubgraphs {
Expand Down
25 changes: 23 additions & 2 deletions inabox/tests/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package integration_test
import (
"context"
"crypto/rand"
"fmt"
"time"

"github.com/Layr-Labs/eigenda/api/clients"
disperserpb "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
"github.com/Layr-Labs/eigenda/common/aws"
"github.com/Layr-Labs/eigenda/core"
auth "github.com/Layr-Labs/eigenda/core/auth/v2"
"github.com/Layr-Labs/eigenda/core/meterer"
corev2 "github.com/Layr-Labs/eigenda/core/v2"
dispv2 "github.com/Layr-Labs/eigenda/disperser/common/v2"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
Expand All @@ -23,11 +26,29 @@ var _ = Describe("Inabox v2 Integration", func() {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

cfg := aws.ClientConfig{
Region: "us-east-1",
AccessKey: "localstack",
SecretAccessKey: "localstack",
EndpointURL: fmt.Sprintf("http://0.0.0.0:%s", localStackPort),
}
fmt.Println("Creating v2 tables IN integration_v2_test.go")

fmt.Println("Creating payment related tables v2")
// create payment related tables
err := meterer.CreateReservationTable(cfg, "e2e_v2_reservation")
fmt.Println("err", err)
Expect(err).To(BeNil())
err = meterer.CreateOnDemandTable(cfg, "e2e_v2_ondemand")
fmt.Println("err", err)
Expect(err).To(BeNil())
err = meterer.CreateGlobalReservationTable(cfg, "e2e_v2_global_reservation")
fmt.Println("err", err)
Expect(err).To(BeNil())

privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcded"
signer := auth.NewLocalBlobRequestSigner(privateKeyHex)

// deploy payment dynamodb tables

disp, err := clients.NewDisperserClientV2(&clients.DisperserClientV2Config{
Hostname: "localhost",
Port: "32005",
Expand Down
2 changes: 1 addition & 1 deletion node/plugin/tests/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func setup(m *testing.M) {
return
}

fmt.Println("Starting anvil")
fmt.Println("Starting anvil node plugin tests plugin_test.go")
testConfig.StartAnvil()

fmt.Println("Deploying experiment")
Expand Down
2 changes: 1 addition & 1 deletion operators/churner/tests/churner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func setup(m *testing.M) {
return
}

fmt.Println("Starting anvil")
fmt.Println("Starting anvil operators churner tests churner_test.go")
testConfig.StartAnvil()

fmt.Println("Deploying experiment")
Expand Down

0 comments on commit f9ec220

Please sign in to comment.