Skip to content

Commit

Permalink
Add atlas-evm-events and atlas-evm-receipts to the atlas stack for e2…
Browse files Browse the repository at this point in the history
…e testing (#131)

* Add atlas-evm-blocks to the atlas stack for e2e testing

* in progress

* in progress

* optimize resources
  • Loading branch information
gheorghestrimtu authored Nov 8, 2021
1 parent e3ed5c4 commit 22d5e3a
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 22 deletions.
21 changes: 20 additions & 1 deletion actions/ocr.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func NewOCRSetupInputForObservability(i *OCRSetupInputs, nodeCount int, contract
By("Funding nodes", FundNodes(i))
By("Deploying OCR contracts", DeployOCRContracts(i, contractCount))


expectations, err := GetMockserverInitializerDataForOTPE(
i.OCRInstances,
i.ChainlinkNodes,
Expand All @@ -269,6 +268,26 @@ func NewOCRSetupInputForAtlas(i *OCRSetupInputs, nodeCount int, contractCount in
i,
environment.NewChainlinkClusterForAtlasTesting(nodeCount),
))

err := i.SuiteSetup.Environment().DeploySpecs(environment.AtlasEvmBlocksGroup())
Expect(err).ShouldNot(HaveOccurred())

By("Funding nodes", FundNodes(i))

kafkaRestClient, err := environment.GetKafkaRestClientFromEnv(i.SuiteSetup.Environment())
Expect(err).ShouldNot(HaveOccurred())

Eventually(func(g Gomega) []string {
topics, err := kafkaRestClient.GetTopics()
g.Expect(err).ShouldNot(HaveOccurred())
return topics
}, "3m", "1s").Should(ContainElements(
ContainSubstring("block_headers"),
ContainSubstring("transactions"),
))

err = i.SuiteSetup.Environment().DeploySpecs(environment.AtlasEvmEventsAndReceiptsGroup())
Expect(err).ShouldNot(HaveOccurred())

By("Deploying OCR contracts", DeployOCRContracts(i, contractCount))
}
29 changes: 29 additions & 0 deletions client/kafka_rest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package client

import "net/http"

// KafkaRestClient kafka-rest client
type KafkaRestClient struct {
*BasicHTTPClient
Config *KafkaRestConfig
}

// KafkaRestConfig holds config information for KafkaRestClient
type KafkaRestConfig struct {
URL string
}

// NewKafkaRestClient creates a new KafkaRestClient
func NewKafkaRestClient(cfg *KafkaRestConfig) *KafkaRestClient {
return &KafkaRestClient{
Config: cfg,
BasicHTTPClient: NewBasicHTTPClient(&http.Client{}, cfg.URL),
}
}

// GetTopics Get a list of Kafka topics.
func (krc *KafkaRestClient) GetTopics() ([]string, error) {
responseBody := []string{}
_, err := krc.do(http.MethodGet, "/topics", nil, &responseBody, http.StatusOK)
return responseBody, err
}
6 changes: 3 additions & 3 deletions environment/charts/kafka/overrideValues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ provisioning:
enabled: true
resources:
limits:
cpu: 250m
memory: 1Gi
cpu: 0.5
memory: 500M
requests:
cpu: 250m
cpu: 0.3
memory: 256Mi
11 changes: 11 additions & 0 deletions environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ func GetMockserverClientFromEnv(env Environment) (*client.MockserverClient, erro
}), nil
}

// GetKafkaRestClientFromEnv returns a KafkaRestClient
func GetKafkaRestClientFromEnv(env Environment) (*client.KafkaRestClient, error) {
sd, err := env.GetServiceDetails(KafkaRestAPIPort)
if err != nil {
return nil, err
}
return client.NewKafkaRestClient(&client.KafkaRestConfig{
URL: sd.LocalURL.String(),
}), nil
}

// GetChainlinkClients will return all instantiated Chainlink clients for a given environment
func GetChainlinkClients(env Environment) ([]client.Chainlink, error) {
var clients []client.Chainlink
Expand Down
67 changes: 61 additions & 6 deletions environment/environment_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
ExplorerAPIPort uint16 = 8080
PrometheusAPIPort uint16 = 9090
MockserverAPIPort uint16 = 1080
KafkaRestAPIPort uint16 = 8082
)

// Ethereum ports
Expand Down Expand Up @@ -438,6 +439,24 @@ func NewAtlasEvmBlocksManifest() *K8sManifest {
}
}

// NewAtlasEvmEventsManifest is the k8s manifest that when used will deploy atlas-evm-events to an env
func NewAtlasEvmEventsManifest() *K8sManifest {
return &K8sManifest{
id: "atlas_evm_events",
DeploymentFile: filepath.Join(utils.ProjectRoot, "/environment/templates/atlas-evm/atlas-evm-events-deployment.yaml"),
ServiceFile: filepath.Join(utils.ProjectRoot, "/environment/templates/atlas-evm/atlas-evm-events-service.yaml"),
}
}

// NewAtlasEvmReceiptsManifest is the k8s manifest that when used will deploy atlas-evm-receipts to an env
func NewAtlasEvmReceiptsManifest() *K8sManifest {
return &K8sManifest{
id: "atlas_evm_receipts",
DeploymentFile: filepath.Join(utils.ProjectRoot, "/environment/templates/atlas-evm/atlas-evm-receipts-deployment.yaml"),
ServiceFile: filepath.Join(utils.ProjectRoot, "/environment/templates/atlas-evm/atlas-evm-receipts-service.yaml"),
}
}

// NewSchemaRegistryManifest is the k8s manifest that when used will deploy schema registry to an env
// Confluent Schema Registry provides a serving layer for your metadata. It provides a RESTful interface for storing
// and retrieving your Avro®, JSON Schema, and Protobuf schemas. In Atlas it stores the schemas for different
Expand All @@ -458,6 +477,16 @@ func NewSchemaRegistryManifest() *K8sManifest {
}
}

// NewKafkaRestManifest is the k8s manifest that when used will deploy kafka rest to an env
// this is used to retrieve kafka info through REST
func NewKafkaRestManifest() *K8sManifest {
return &K8sManifest{
id: "kafka_rest",
DeploymentFile: filepath.Join(utils.ProjectRoot, "/environment/templates/kafka-rest/kafka-rest-deployment.yaml"),
ServiceFile: filepath.Join(utils.ProjectRoot, "/environment/templates/kafka-rest/kafka-rest-service.yaml"),
}
}

// NewChainlinkCluster is a basic environment that deploys hardhat with a chainlink cluster and an external adapter
func NewChainlinkCluster(nodeCount int) K8sEnvSpecInit {
mockserverConfigDependencyGroup := &K8sManifestGroup{
Expand Down Expand Up @@ -555,9 +584,9 @@ func NewChainlinkClusterForAtlasTesting(nodeCount int) K8sEnvSpecInit {
manifests: []K8sEnvResource{NewSchemaRegistryManifest()},
}

atlasEvmBlocksDependencyGroup := &K8sManifestGroup{
id: "AtlasEvmBlocksGroup",
manifests: []K8sEnvResource{NewAtlasEvmBlocksManifest()},
kafkaRestDependencyGroup := &K8sManifestGroup{
id: "KafkaRestGroup",
manifests: []K8sEnvResource{NewKafkaRestManifest()},
}

dependencyGroup := getBasicDependencyGroup()
Expand All @@ -567,7 +596,7 @@ func NewChainlinkClusterForAtlasTesting(nodeCount int) K8sEnvSpecInit {
mockserverDependencyGroup,
kafkaDependecyGroup,
schemaRegistryDependencyGroup,
atlasEvmBlocksDependencyGroup,
kafkaRestDependencyGroup,
dependencyGroup,
}

Expand Down Expand Up @@ -761,9 +790,7 @@ func OtpeGroup() K8sEnvSpecInit {
id: "OTPEDependencyGroup",
manifests: []K8sEnvResource{NewOTPEManifest()},
}

specs = append(specs, otpeDependencyGroup)

return specs
}
}
Expand All @@ -780,3 +807,31 @@ func PrometheusGroup(rules map[string]*os.File) K8sEnvSpecInit {
return specs
}
}

// AtlasEvmBlocksGroup contains manifests for atlas-evm-blocks
func AtlasEvmBlocksGroup() K8sEnvSpecInit {
return func(networks ...client.BlockchainNetwork) K8sEnvSpecs {
var specs K8sEnvSpecs
atlasEvmBlocksDependencyGroup := &K8sManifestGroup{
id: "AtlasEvmBlocksGroup",
manifests: []K8sEnvResource{NewAtlasEvmBlocksManifest()},
}
specs = append(specs, atlasEvmBlocksDependencyGroup)
return specs
}
}

// AtlasEvmEventsAndReceiptsGroup contains manifests for atlas-evm-events and atlas-evm-receipts
func AtlasEvmEventsAndReceiptsGroup() K8sEnvSpecInit {
return func(networks ...client.BlockchainNetwork) K8sEnvSpecs {
var specs K8sEnvSpecs

atlasEvmEventsAndReceiptsDependencyGroup := &K8sManifestGroup{
id: "AtlasEvmEventsAndReceiptsGroup",
manifests: []K8sEnvResource{NewAtlasEvmEventsManifest(), NewAtlasEvmReceiptsManifest()},
}

specs = append(specs, atlasEvmEventsAndReceiptsDependencyGroup)
return specs
}
}
12 changes: 8 additions & 4 deletions environment/templates/atlas-evm/atlas-evm-blocks-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ spec:
value: debug
- name: RPC_ENDPOINTS
value: {{ .DefaultNetwork.ClusterURL }}
- name: CHAIN_ID
value: {{ .DefaultNetwork.ChainID }}
- name: NETWORK_NAME
value: {{ .DefaultNetwork.Name }}
image: {{ .Config.Apps.AtlasEvm.Image }}:{{ .Config.Apps.AtlasEvm.Version }}
ports:
- containerPort: 9090
resources:
requests:
memory: "250Mi"
cpu: "1"
memory: 200M
cpu: 0.25
limits:
memory: "250Mi"
cpu: "1"
memory: 350m
cpu: 0.4
43 changes: 43 additions & 0 deletions environment/templates/atlas-evm/atlas-evm-events-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
metadata:
name: atlas-evm-events
spec:
replicas: 1
selector:
matchLabels:
app: atlas-evm-events
template:
objectmeta:
labels:
app: atlas-evm-events
spec:
containers:
- name: atlas-evm-events
args:
- events
env:
- name: KAFKA_BROKERS
value: {{ .Values.KafkaGroup.kafka.clusterURL }}
- name: KAFKA_CLIENT_ID
value: "explorer"
- name: KAFKA_SCHEMA_REGISTRY_URL
value: {{ .Values.SchemaRegistryGroup.schema_registry.clusterURL }}
- name: KAFKA_SECURITY_PROTOCOL
value: PLAINTEXT
- name: LOG_LEVEL
value: debug
- name: RPC_ENDPOINTS
value: {{ .DefaultNetwork.ClusterURL }}
- name: CHAIN_ID
value: {{ .DefaultNetwork.ChainID }}
- name: NETWORK_NAME
value: {{ .DefaultNetwork.Name }}
image: {{ .Config.Apps.AtlasEvm.Image }}:{{ .Config.Apps.AtlasEvm.Version }}
ports:
- containerPort: 9090
resources:
requests:
memory: 200M
cpu: 0.25
limits:
memory: 350m
cpu: 0.4
10 changes: 10 additions & 0 deletions environment/templates/atlas-evm/atlas-evm-events-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
metadata:
name: atlas-evm-events
spec:
ports:
- name: "9095"
port: 9095
targetPort: 9090
selector:
app: atlas-evm-events
type: ClusterIP
43 changes: 43 additions & 0 deletions environment/templates/atlas-evm/atlas-evm-receipts-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
metadata:
name: atlas-evm-receipts
spec:
replicas: 1
selector:
matchLabels:
app: atlas-evm-receipts
template:
objectmeta:
labels:
app: atlas-evm-receipts
spec:
containers:
- name: atlas-evm-receipts
args:
- receipts
env:
- name: KAFKA_BROKERS
value: {{ .Values.KafkaGroup.kafka.clusterURL }}
- name: KAFKA_CLIENT_ID
value: "explorer"
- name: KAFKA_SCHEMA_REGISTRY_URL
value: {{ .Values.SchemaRegistryGroup.schema_registry.clusterURL }}
- name: KAFKA_SECURITY_PROTOCOL
value: PLAINTEXT
- name: LOG_LEVEL
value: debug
- name: RPC_ENDPOINTS
value: {{ .DefaultNetwork.ClusterURL }}
- name: CHAIN_ID
value: {{ .DefaultNetwork.ChainID }}
- name: NETWORK_NAME
value: {{ .DefaultNetwork.Name }}
image: {{ .Config.Apps.AtlasEvm.Image }}:{{ .Config.Apps.AtlasEvm.Version }}
ports:
- containerPort: 9090
resources:
requests:
memory: 200M
cpu: 0.25
limits:
memory: 350m
cpu: 0.4
10 changes: 10 additions & 0 deletions environment/templates/atlas-evm/atlas-evm-receipts-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
metadata:
name: atlas-evm-receipts
spec:
ports:
- name: "9094"
port: 9094
targetPort: 9090
selector:
app: atlas-evm-receipts
type: ClusterIP
8 changes: 4 additions & 4 deletions environment/templates/explorer-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ spec:
- containerPort: 5432
resources:
requests:
memory: "256Mi"
cpu: "500m"
memory: 250m
cpu: 0.5
limits:
memory: "512Mi"
cpu: "1024m"
memory: 500m
cpu: 0.8
env:
- name: POSTGRES_DB
value: explorer_production
Expand Down
Loading

0 comments on commit 22d5e3a

Please sign in to comment.