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 1bf965f
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 13 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
57 changes: 57 additions & 0 deletions inabox/deploy/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,63 @@ 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")

v2TableName := "test_v2"
fmt.Println("Creating payment related tables")
// create payment related tables
err := meterer.CreateReservationTable(cfg, v2TableName+"_reservation")
if err != nil {
return err
}
err = meterer.CreateOnDemandTable(cfg, v2TableName+"_ondemand")
if err != nil {
return err
}
err = meterer.CreateGlobalReservationTable(cfg, v2TableName+"_global_reservation")
if err != nil {
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
2 changes: 0 additions & 2 deletions inabox/tests/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ var _ = Describe("Inabox v2 Integration", func() {
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 1bf965f

Please sign in to comment.