Skip to content

Commit

Permalink
Merge pull request #35 from napptive/PG-447/ImproveCache
Browse files Browse the repository at this point in the history
Pg 447/improve cache
  • Loading branch information
Carmendelope authored Aug 9, 2021
2 parents 8544a17 + 929ba53 commit 8279eb5
Show file tree
Hide file tree
Showing 15 changed files with 274 additions and 521 deletions.
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BUILD_FOLDER=$(CURDIR)/build
BIN_FOLDER=$(BUILD_FOLDER)/bin
DOCKER_FOLDER=$(BUILD_FOLDER)/docker
K8S_FOLDER=$(BUILD_FOLDER)/k8s
TEMP_FOLDER=$(CURDIR)/temp

# Obtain the last commit hash
COMMIT=$(shell git log -1 --pretty=format:"%H")
Expand Down Expand Up @@ -191,3 +192,35 @@ release: clean build-darwin build-linux k8s
@echo "::set-output name=release_file::$(BUILD_FOLDER)/$(PROJECT_NAME)_$(VERSION).tar.gz"
@echo "::set-output name=release_name::$(PROJECT_NAME)_$(VERSION).tar.gz"

.PHONY: prepare-integration-test-environment
prepare-integration-test-environment:
@echo "Preparing integration tests environment"
@echo "Launch elastic docker container..."
@docker run -d --name elastic-env -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.13.1
@echo "Wait several seconds until elastic is ready"
@sleep 10
@echo "Elastic ready!"
@docker run -d --name local-postgres -e POSTGRES_PASSWORD=Pass2020! -p 5432:5432 postgres:13-alpine
@echo "Database ready!"

.PHONY: it-load-db-schema
it-load-db-schema:
@mkdir $(TEMP_FOLDER) || true
@kubectl create -f deployments/$(PROJECT_NAME).005.configmap.all.all.yaml --dry-run=client -o "jsonpath={.data['$(PROJECT_NAME)-sql-script\.yaml']}" > $(TEMP_FOLDER)/db.yaml
@docker run -it --network host -v $(TEMP_FOLDER):/it napptive/rdbms:latest schema load --scriptLoadPath=/it/db.yaml
@echo "database schema has been loaded"

.PHONY: remove-integration-test-environment
remove-integration-test-environment:
@echo "Removing integration tests environment"
@docker stop elastic-env
@docker rm elastic-env
@echo "elastic removed!"
@docker stop local-postgres
@docker rm local-postgres
@echo "postgres removed!"

.PHONY: all-tests
all-tests:
@echo "Executing unit and integration tests"
RUN_INTEGRATION_TEST=all IT_RUN_LOCAL=true $(GO_TEST) -v ./...
10 changes: 5 additions & 5 deletions deployments/elastic.020.statefulset.aks.all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ spec:
image: elasticsearch:7.11.2
resources:
requests:
memory: "3Gi"
cpu: "250m"
memory: "8Gi"
cpu: "2"
limits:
memory: "3Gi"
cpu: "250m"
memory: "8Gi"
cpu: "2"
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 9200
Expand All @@ -46,7 +46,7 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: ES_JAVA_OPTS
value: -Xms2g -Xmx2g
value: -Xms4g -Xmx4g
- name: cluster.initial_master_nodes
value: elastic-0
initContainers:
Expand Down
10 changes: 5 additions & 5 deletions deployments/elastic.020.statefulset.gcp.all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ spec:
image: elasticsearch:7.11.2
resources:
requests:
memory: "3Gi"
cpu: "250m"
memory: "8Gi"
cpu: "2"
limits:
memory: "3Gi"
cpu: "250m"
memory: "8Gi"
cpu: "2"
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 9200
Expand All @@ -46,7 +46,7 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: ES_JAVA_OPTS
value: -Xms2g -Xmx2g
value: -Xms4g -Xmx4g
- name: cluster.initial_master_nodes
value: elastic-0
initContainers:
Expand Down
26 changes: 1 addition & 25 deletions internal/pkg/provider/metadata/elastic_it_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package metadata

import (
"strings"
"time"

"github.com/napptive/catalog-manager/internal/pkg/entities"
"github.com/napptive/catalog-manager/internal/pkg/utils"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"github.com/rs/zerolog/log"
"strings"
"syreclabs.com/go/faker"
)

Expand Down Expand Up @@ -36,25 +33,4 @@ var _ = ginkgo.Describe("Elastic Provider test", func() {

RunTests(provider)

ginkgo.It("Getting an application metadata by Search Method", func() {
app := utils.CreateTestApplicationInfo()

returned, err := provider.Add(app)
gomega.Expect(err).Should(gomega.Succeed())
gomega.Expect(returned).ShouldNot(gomega.BeNil())

// wait to be stored
time.Sleep(time.Second)

retrieved, err := provider.SearchByApplicationID(entities.ApplicationID{
Namespace: returned.Namespace,
ApplicationName: returned.ApplicationName,
Tag: returned.Tag,
})
gomega.Expect(err).Should(gomega.Succeed())
gomega.Expect(retrieved).ShouldNot(gomega.BeNil())
gomega.Expect(*retrieved).Should(gomega.Equal(*app))
})


})
Loading

0 comments on commit 8279eb5

Please sign in to comment.