Skip to content

Commit

Permalink
test: ✅ setup localstack
Browse files Browse the repository at this point in the history
  • Loading branch information
ignazio-bovo committed Jun 17, 2024
1 parent 8ae8d77 commit ae510bc
Show file tree
Hide file tree
Showing 12 changed files with 24,425 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ LOCALSTACK_ENABLED=false
LOCALSTACK_PORT=4566

## Specify the cloud storage provider to use:
CLOUD_STORAGE_PROVIDER_NAME="aws"
CLOUD_STORAGE_PROVIDER_NAME=aws

# AWS S3 (replace with your own configuration and credentials)
AWS_ACCESS_KEY_ID="test-key"
AWS_SECRET_ACCESS_KEY="test-secret"
AWS_REGION="eu-west-1"
AWS_BUCKET_NAME="sample-bucket"
AWS_ACCESS_KEY_ID=test-key
AWS_SECRET_ACCESS_KEY=test-secret
AWS_REGION=eu-west-1
AWS_BUCKET_NAME=sample-bucket
2 changes: 1 addition & 1 deletion cli/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default class Api {
return new Date(blockTime.toNumber())
}

protected workingGroupApiQuery<T extends WorkingGroups>(group: T): ApiPromise['query'][typeof apiModuleByGroup[T]] {
protected workingGroupApiQuery<T extends WorkingGroups>(group: T): ApiPromise['query'][(typeof apiModuleByGroup)[T]] {
const module = apiModuleByGroup[group]
return this._api.query[module]
}
Expand Down
8 changes: 4 additions & 4 deletions cli/src/base/ContentDirectoryCommandBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const CATEGORIES_CONTEXTS = ['Lead', 'Curator'] as const
const MODERATION_ACTION_CONTEXTS = ['Lead', 'Curator'] as const
const CHANNEL_MANAGEMENT_CONTEXTS = ['Owner', 'Curator', 'Collaborator'] as const

type ChannelManagementContext = typeof CHANNEL_MANAGEMENT_CONTEXTS[number]
type ChannelCreationContext = typeof CHANNEL_CREATION_CONTEXTS[number]
type CategoriesContext = typeof CATEGORIES_CONTEXTS[number]
type ModerationActionContext = typeof MODERATION_ACTION_CONTEXTS[number]
type ChannelManagementContext = (typeof CHANNEL_MANAGEMENT_CONTEXTS)[number]
type ChannelCreationContext = (typeof CHANNEL_CREATION_CONTEXTS)[number]
type CategoriesContext = (typeof CATEGORIES_CONTEXTS)[number]
type ModerationActionContext = (typeof MODERATION_ACTION_CONTEXTS)[number]

/**
* Abstract base class for commands related to content directory
Expand Down
2 changes: 1 addition & 1 deletion cli/src/base/ForumCommandBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { AccountId } from '@polkadot/types/interfaces'
const FORUM_MODERATION_CONTEXT = ['Leader', 'Moderator'] as const

type ForumModerationContext = typeof FORUM_MODERATION_CONTEXT[number]
type ForumModerationContext = (typeof FORUM_MODERATION_CONTEXT)[number]

/**
* Abstract base class for commands related to forum management
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/api/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const TYPES_AVAILABLE = ['query', 'consts'] as const

// String literals type based on TYPES_AVAILABLE const.
// It works as if we specified: type ApiType = 'query' | 'consts'...;
type ApiType = typeof TYPES_AVAILABLE[number]
type ApiType = (typeof TYPES_AVAILABLE)[number]

export default class ApiInspect extends ApiCommandBase {
static description =
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helpers/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function displayTable(rows: { [k: string]: string | number }[], cellHoriz
}, columnName.length)
const columnDef = (columnName: string) => ({
header: columnName,
get: (row: typeof rows[number]) => chalk.magentaBright(`${row[columnName]}`),
get: (row: (typeof rows)[number]) => chalk.magentaBright(`${row[columnName]}`),
minWidth: maxLength(columnName) + cellHorizontalPadding,
})
const columns: Table.table.Columns<{ [k: string]: string }> = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
S3Client,
} from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
import logger from '../logger'
import fs from 'fs'

export type AwsConnectionHandlerParams = {
Expand Down Expand Up @@ -41,6 +42,7 @@ export class AwsConnectionHandler implements IConnectionHandler {
forcePathStyle: process.env.LOCALSTACK_ENABLED === 'true',
})
this.bucket = opts.bucketName
logger.info(`AWS connection handler initialized with bucket: ${this.bucket}`)
}

private isSuccessfulResponse(response: any): boolean {
Expand Down
2 changes: 1 addition & 1 deletion storage-node/src/services/webApi/controllers/stateApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../types'
import { AppConfig, sendResponseWithError } from './common'
import { getDataObjectIDs } from '../../../services/caching/localDataObjects'
import { isStorageProviderConnectionEnabled } from 'src/commands/server'
import { isStorageProviderConnectionEnabled } from '../../../commands/server'
const fsPromises = fs.promises

// Expiration period in seconds for the local cache.
Expand Down
2 changes: 1 addition & 1 deletion tests/network-tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ if [ "${NO_STORAGE}" != true ]; then
fi

# Execute tests
# ./run-test-scenario.sh $*
./run-test-scenario.sh $*
2 changes: 1 addition & 1 deletion tests/network-tests/src/cli/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export abstract class CLI {
)

const response = {
exitCode,
exitCode: Number(exitCode),
stdout,
stderr,
out: stdout.trim(),
Expand Down
9 changes: 9 additions & 0 deletions tests/network-tests/start-storage.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set -e

source ../../.env

TMP=$0
THIS_DIR=$(dirname $TMP)

Expand All @@ -24,6 +26,13 @@ docker-compose -f $THIS_DIR/../../docker-compose.yml up -d distributor-1
docker-compose -f $THIS_DIR/../../docker-compose.yml up -d colossus-2
docker-compose -f $THIS_DIR/../../docker-compose.yml up -d distributor-2

# Start localstack if ENABLE_LOCALSTACK is set to true
if [ "$LOCALSTACK_ENABLED" == "true" ]; then
docker-compose -f $THIS_DIR/../../docker-compose.yml up -d localstack
awslocal s3api create-bucket --bucket "$AWS_BUCKET_NAME"

fi

# allow a few seconds for nodes to startup and display first few log entries
# to help debug tests
sleep 30
Expand Down
Loading

0 comments on commit ae510bc

Please sign in to comment.