Skip to content

Commit

Permalink
Merge pull request #90 from smartcontractkit/chore/separate-explorer
Browse files Browse the repository at this point in the history
separate explorer
  • Loading branch information
gheorghestrimtu authored Sep 8, 2021
2 parents b7fdc0f + 70882ee commit 01fdca9
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 29 deletions.
82 changes: 55 additions & 27 deletions environment/environment_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,25 @@ func NewChainlinkCluster(nodeCount int) K8sEnvSpecInit {
chainlinkGroup.manifests = append(chainlinkGroup.manifests, cManifest)
}

return addDependencyGroup(nodeCount, "basic-chainlink", chainlinkGroup)
dependencyGroup := getBasicDependencyGroup()
addPostgresDbsToDependencyGroup(dependencyGroup, nodeCount)
return addNetworkManifestToDependencyGroup("basic-chainlink", dependencyGroup, chainlinkGroup)
}

func NewChainlinkClusterForAlertsTesting(nodeCount int) K8sEnvSpecInit {
chainlinkGroup := &K8sManifestGroup{
id: "chainlinkCluster",
manifests: []K8sEnvResource{},
}
for i := 0; i < nodeCount; i++ {
cManifest := NewChainlinkManifest()
cManifest.id = fmt.Sprintf("%s-%d", cManifest.id, i)
chainlinkGroup.manifests = append(chainlinkGroup.manifests, cManifest)
}
dependencyGroup := getBasicDependencyGroup()
addPostgresDbsToDependencyGroup(dependencyGroup, nodeCount)
addServicesForTestingAlertsToDependencyGroup(dependencyGroup, nodeCount)
return addNetworkManifestToDependencyGroup("basic-chainlink", dependencyGroup, chainlinkGroup)
}

// NewMixedVersionChainlinkCluster mixes the currently latest chainlink version (as defined by the config file) with
Expand Down Expand Up @@ -261,7 +279,9 @@ func NewMixedVersionChainlinkCluster(nodeCount, pastVersionsCount int) K8sEnvSpe
chainlinkGroup.manifests = append(chainlinkGroup.manifests, cManifest)
}

return addDependencyGroup(nodeCount, "mixed-version-chainlink", chainlinkGroup)
dependencyGroup := getBasicDependencyGroup()
addPostgresDbsToDependencyGroup(dependencyGroup, nodeCount)
return addNetworkManifestToDependencyGroup("mixed-version-chainlink", dependencyGroup, chainlinkGroup)
}

// NewGethReorgHelmChart creates new helm chart for multi-node Geth network
Expand Down Expand Up @@ -306,9 +326,8 @@ func getMixedVersions(versionCount int) ([]string, error) {
return mixedVersions, nil
}

// addDependencyGroup add everything that has no dependencies but other pods have
// dependencies on in the first group
func addDependencyGroup(nodeCount int, envName string, chainlinkGroup *K8sManifestGroup) K8sEnvSpecInit {
// getBasicDependencyGroup returns a manifest group containing the basic setup for a chainlink deployment
func getBasicDependencyGroup() *K8sManifestGroup {
group := &K8sManifestGroup{
id: "DependencyGroup",
manifests: []K8sEnvResource{NewAdapterManifest()},
Expand All @@ -327,40 +346,49 @@ func addDependencyGroup(nodeCount int, envName string, chainlinkGroup *K8sManife
return nil
},
}
for i := 0; i < nodeCount; i++ {
pManifest := NewPostgresManifest()
pManifest.id = fmt.Sprintf("%s-%d", pManifest.id, i)
group.manifests = append(group.manifests, pManifest)
}
return group
}

// addNetworkManifestToDependencyGroup adds the correct network to the dependency group and returns
// an array of all groups, this should be called as the last function when creating deploys
func addNetworkManifestToDependencyGroup(envName string, dependencyGroup *K8sManifestGroup, chainlinkGroup *K8sManifestGroup) K8sEnvSpecInit {
return func(config *config.NetworkConfig) (string, K8sEnvSpecs) {
switch config.Name {
case "Ethereum Geth reorg":
group.manifests = append(
group.manifests,
NewGethReorgHelmChart(),
)
dependencyGroup.manifests = append(
dependencyGroup.manifests,
NewGethReorgHelmChart())
case "Ethereum Geth dev":
group.manifests = append(
group.manifests,
NewGethManifest(),
NewExplorerManifest(nodeCount))
dependencyGroup.manifests = append(
dependencyGroup.manifests,
NewGethManifest())
case "Ethereum Hardhat":
group.manifests = append(
group.manifests,
dependencyGroup.manifests = append(
dependencyGroup.manifests,
NewHardhatManifest())
case "Ethereum Ganache":
group.manifests = append(
group.manifests,
dependencyGroup.manifests = append(
dependencyGroup.manifests,
NewGanacheManifest())
default: // no simulated chain
group.manifests = append(
group.manifests,
NewExplorerManifest(nodeCount))
}
if len(chainlinkGroup.manifests) > 0 {
return envName, K8sEnvSpecs{group, chainlinkGroup}
return envName, K8sEnvSpecs{dependencyGroup, chainlinkGroup}
}
return envName, K8sEnvSpecs{group}
return envName, K8sEnvSpecs{dependencyGroup}
}
}

// addPostgresDbsToDependencyGroup adds a postgresCount number of postgres dbs to the dependency group
func addPostgresDbsToDependencyGroup(dependencyGroup *K8sManifestGroup, postgresCount int) {
for i := 0; i < postgresCount; i++ {
pManifest := NewPostgresManifest()
pManifest.id = fmt.Sprintf("%s-%d", pManifest.id, i)
dependencyGroup.manifests = append(dependencyGroup.manifests, pManifest)
}
}

// addServicesForTestingAlertsToDependencyGroup adds services necessary for testing alerts to the dependency group
func addServicesForTestingAlertsToDependencyGroup(dependencyGroup *K8sManifestGroup, nodeCount int) {
dependencyGroup.manifests = append(dependencyGroup.manifests, NewExplorerManifest(nodeCount))
}
7 changes: 6 additions & 1 deletion environment/k8s_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,18 @@ func next(array *TemplateValuesArray) (interface{}, error) {
return val, nil
}

func present(name string, data map[string]interface{}) bool {
_, ok := data[name]
return ok
}

func (m *K8sManifest) parse(path string, obj interface{}, data interface{}) error {
fileBytes, err := ioutil.ReadFile(path)
if err != nil {
return fmt.Errorf("failed to read k8s file: %v", err)
}

var funcs = template.FuncMap{"next": next}
var funcs = template.FuncMap{"next": next, "present": present}

tpl, err := template.New(path).Funcs(funcs).Parse(string(fileBytes))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions environment/templates/chainlink/chainlink-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ spec:
value: "200000"
- name: KEEPER_REGISTRY_PERFORM_GAS_OVERHEAD
value: "150000"
{{ if (present "explorer" .Values.DependencyGroup) }}
- name: EXPLORER_URL
value: {{ .Values.DependencyGroup.explorer.clusterURL }}
{{ with $x := next .Values.DependencyGroup.explorer.keys }}
Expand All @@ -91,6 +92,7 @@ spec:
- name: EXPLORER_SECRET
value: {{ $x.Secret }}
{{ end }}
{{ end }}
volumeMounts:
- name: node-secrets-volume
readonly: false
Expand Down
2 changes: 1 addition & 1 deletion suite/contracts/contracts_alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("Alerts suite", func() {
BeforeEach(func() {
By("Deploying the environment", func() {
suiteSetup, err = actions.DefaultLocalSetup(
environment.NewChainlinkCluster(3),
environment.NewChainlinkClusterForAlertsTesting(3),
client.NewNetworkFromConfig,
tools.ProjectRoot,
)
Expand Down

2 comments on commit 01fdca9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

15.62%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
client
   chainlink_models.go0%100%100%0%238–247, 255–257, 259–265, 272–274, 276–295, 303–305, 307–325, 335–347, 364–386, 395–403, 419–440, 465–477, 479–533, 546–560, 567–575, 578–583, 586–591
   prometheus.go0%100%100%0%27–36, 39–42, 45–50, 54–65, 69–80, 83–92
   explorer.go0%100%100%0%16–21, 25–36
   basic_http_client.go10.61%100%100%10.61%100–106, 38–43, 51–63, 65–70, 72–92, 94–99
   blockchain.go45.19%100%100%45.19%102–104, 107–109, 112–114, 127–131, 150–152, 160–165, 171–172, 193–194, 202–204, 207–209, 216–217, 222–223, 235–236, 37–40, 42, 78–79, 84–88, 92–94, 97–99
   chainlink.go66.19%100%100%66.19%100–103, 107–112, 147–152, 249–254, 257–262, 289–291, 298–299, 306–307, 310–316, 318–324, 326–327, 337–338, 348–350, 366–367, 378–379, 383–389, 391, 393, 395–401, 408–414, 427–428, 78–80, 93–99
   ethereum.go0%100%100%0%100–101, 104–114, 116–117, 119–123, 128–130, 133–145, 151–153, 160–174, 178–199, 201, 211–224, 226–240, 244–250, 252–258, 260, 268–285, 294–307, 316–340, 344–354, 356, 360–368, 372–376, 379–383, 385–392, 394, 396, 399–416, 421–429, 43, 430–431, 433–438, 44, 440–442, 445–449, 45, 450–459, 46, 460–461, 464, 47, 472–479, 48, 480–493, 509–519, 52, 520–521, 525–529, 53, 530–539, 54, 540–542, 546–549, 55, 550–553, 56, 562–564, 567–569, 57, 69–73, 75–88, 92–96, 99
config
   config.go92.86%100%100%92.86%190–191
environment
   k8s_environment.go0%100%100%0%100, 1005–1009, 101, 1010–1019, 102, 1020–1021, 1024–1029, 103, 1030, 1033, 1036–1039, 104, 1040–1043, 1047–1049, 105, 1050–1054, 1056, 106, 1066–1069, 107, 1070–1071, 1073–1079, 108, 1080, 1082, 1086–1089, 109, 1090, 1092, 1095–1099, 110, 1102–1106, 1108–1109, 111, 1110–1119, 112, 1120, 1123–1125, 1128–1129, 113, 1130–1139, 114, 1140–1145, 115, 1150, 116–136, 138–139, 142, 146–150, 154–163, 165–168, 170–173, 177–182, 187–193, 196–202, 204–211, 216–221, 225–229, 233–237, 242–246, 249–251, 255–261, 264–271, 273–275, 278, 282–309, 312–317, 321–326, 328–332, 334–342, 344–349, 351, 354–371, 373, 376–392, 436–439, 443–445, 447–449, 451–453, 456–469, 474–494, 498–500, 502–504, 506–517, 520–523, 527–541, 543, 547–555, 557–562, 565–568, 570–587, 589–598, 602–604, 607–611, 614–619, 621–633, 635, 640–653, 655–667, 669, 672–677, 679–691, 693, 696–709, 711, 718–723, 725, 732–741, 743, 750–759, 761, 768–777, 779, 786–793, 795–807, 809–813, 817–824, 836–843, 846–853, 856–859, 861–865, 867–869, 87, 870–879, 88, 880–881, 884–888, 89, 890–899, 90, 900–903, 905–907, 909, 91, 910–918, 92, 921–929, 93, 932–934, 94–95, 952–954, 956–957, 959, 96, 960–961, 964–968, 97, 970, 974–979, 98, 980–987, 99, 990–994, 998–999
   k8s_helm_resource.go0%100%100%0%100, 103–114, 116, 119–121, 123–138, 141, 144–149, 151–165, 167–182, 47–56, 59–61, 63–65, 67–69, 71–73, 75–78, 80–98
   environment_templates.go36.24%100%100%36.24%100–117, 123–138, 140–147, 149–160, 162–163, 169–188, 193–211, 232–245, 252–256, 266–267, 288–302, 304–305, 320–321, 336–341, 344–346, 356–373, 375–378, 39, 392–394, 40–49, 86–93, 98–99
   environment.go8.25%100%100%8.25%101–110, 113–126, 131–139, 145–151, 153–156, 158, 166–171, 35–41, 44–49, 53–70, 72, 91–93, 96–98

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

15.62%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
client
   chainlink_models.go0%100%100%0%238–247, 255–257, 259–265, 272–274, 276–295, 303–305, 307–325, 335–347, 364–386, 395–403, 419–440, 465–477, 479–533, 546–560, 567–575, 578–583, 586–591
   ethereum.go0%100%100%0%100–101, 104–114, 116–117, 119–123, 128–130, 133–145, 151–153, 160–174, 178–199, 201, 211–224, 226–240, 244–250, 252–258, 260, 268–285, 294–307, 316–340, 344–354, 356, 360–368, 372–376, 379–383, 385–392, 394, 396, 399–416, 421–429, 43, 430–431, 433–438, 44, 440–442, 445–449, 45, 450–459, 46, 460–461, 464, 47, 472–479, 48, 480–493, 509–519, 52, 520–521, 525–529, 53, 530–539, 54, 540–542, 546–549, 55, 550–553, 56, 562–564, 567–569, 57, 69–73, 75–88, 92–96, 99
   blockchain.go45.19%100%100%45.19%102–104, 107–109, 112–114, 127–131, 150–152, 160–165, 171–172, 193–194, 202–204, 207–209, 216–217, 222–223, 235–236, 37–40, 42, 78–79, 84–88, 92–94, 97–99
   chainlink.go66.19%100%100%66.19%100–103, 107–112, 147–152, 249–254, 257–262, 289–291, 298–299, 306–307, 310–316, 318–324, 326–327, 337–338, 348–350, 366–367, 378–379, 383–389, 391, 393, 395–401, 408–414, 427–428, 78–80, 93–99
   explorer.go0%100%100%0%16–21, 25–36
   prometheus.go0%100%100%0%27–36, 39–42, 45–50, 54–65, 69–80, 83–92
   basic_http_client.go10.61%100%100%10.61%100–106, 38–43, 51–63, 65–70, 72–92, 94–99
config
   config.go92.86%100%100%92.86%190–191
environment
   environment.go8.25%100%100%8.25%101–110, 113–126, 131–139, 145–151, 153–156, 158, 166–171, 35–41, 44–49, 53–70, 72, 91–93, 96–98
   environment_templates.go36.24%100%100%36.24%100–117, 123–138, 140–147, 149–160, 162–163, 169–188, 193–211, 232–245, 252–256, 266–267, 288–302, 304–305, 320–321, 336–341, 344–346, 356–373, 375–378, 39, 392–394, 40–49, 86–93, 98–99
   k8s_environment.go0%100%100%0%100, 1005–1009, 101, 1010–1019, 102, 1020–1021, 1024–1029, 103, 1030, 1033, 1036–1039, 104, 1040–1043, 1047–1049, 105, 1050–1054, 1056, 106, 1066–1069, 107, 1070–1071, 1073–1079, 108, 1080, 1082, 1086–1089, 109, 1090, 1092, 1095–1099, 110, 1102–1106, 1108–1109, 111, 1110–1119, 112, 1120, 1123–1125, 1128–1129, 113, 1130–1139, 114, 1140–1145, 115, 1150, 116–136, 138–139, 142, 146–150, 154–163, 165–168, 170–173, 177–182, 187–193, 196–202, 204–211, 216–221, 225–229, 233–237, 242–246, 249–251, 255–261, 264–271, 273–275, 278, 282–309, 312–317, 321–326, 328–332, 334–342, 344–349, 351, 354–371, 373, 376–392, 436–439, 443–445, 447–449, 451–453, 456–469, 474–494, 498–500, 502–504, 506–517, 520–523, 527–541, 543, 547–555, 557–562, 565–568, 570–587, 589–598, 602–604, 607–611, 614–619, 621–633, 635, 640–653, 655–667, 669, 672–677, 679–691, 693, 696–709, 711, 718–723, 725, 732–741, 743, 750–759, 761, 768–777, 779, 786–793, 795–807, 809–813, 817–824, 836–843, 846–853, 856–859, 861–865, 867–869, 87, 870–879, 88, 880–881, 884–888, 89, 890–899, 90, 900–903, 905–907, 909, 91, 910–918, 92, 921–929, 93, 932–934, 94–95, 952–954, 956–957, 959, 96, 960–961, 964–968, 97, 970, 974–979, 98, 980–987, 99, 990–994, 998–999
   k8s_helm_resource.go0%100%100%0%100, 103–114, 116, 119–121, 123–138, 141, 144–149, 151–165, 167–182, 47–56, 59–61, 63–65, 67–69, 71–73, 75–78, 80–98

Please sign in to comment.