Skip to content

Commit

Permalink
Merge branch 'main' into refactor-add-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rokshana-b committed Feb 8, 2022
2 parents 3271ba8 + b091349 commit 4e5b5b1
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 101 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ local-registry:
./tools/deploy-local-registry.sh

local-docker-image:
docker build -t localhost:5000/wego-app:latest .
docker push localhost:5000/wego-app:latest
docker build -t localhost:5001/wego-app:latest .
docker push localhost:5001/wego-app:latest

fakes: ## Generate testing fakes
go generate ./...
Expand Down
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local_resource(
)

docker_build_with_restart(
'localhost:5000/weaveworks/wego-app',
'localhost:5001/weaveworks/wego-app',
'.',
only=[
'./bin',
Expand Down
16 changes: 9 additions & 7 deletions pkg/models/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ import (
"strconv"
"strings"

"github.com/fluxcd/go-git-providers/gitprovider"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation"

corev1 "k8s.io/api/core/v1"

"github.com/fluxcd/go-git-providers/gitprovider"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/yaml"

"github.com/weaveworks/weave-gitops/cmd/gitops/version"
"github.com/weaveworks/weave-gitops/manifests"
"github.com/weaveworks/weave-gitops/pkg/flux"
"github.com/weaveworks/weave-gitops/pkg/git"
"github.com/weaveworks/weave-gitops/pkg/gitproviders"
"github.com/weaveworks/weave-gitops/pkg/kube"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/yaml"
)

type Manifest struct {
Expand All @@ -48,7 +46,7 @@ const (

WegoConfigMapName = "weave-gitops-config"
WegoImage = "ghcr.io/weaveworks/wego-app"
localWegoImage = "localhost:5000/wego-app"
localWegoImage = "localhost:5001/wego-app"
)

type ManifestsParams struct {
Expand Down Expand Up @@ -186,6 +184,10 @@ func NoClusterApplicableManifests(params ManifestsParams) ([]Manifest, error) {
Path: git.GetSystemQualifiedPath(params.ClusterName, SystemKustomizationPath),
Content: systemKustomizationManifest,
},
{
Path: git.GetSystemQualifiedPath(params.ClusterName, WegoProfilesPath),
Content: []byte(""),
},
{
Path: filepath.Join(git.GetUserPath(params.ClusterName), ".keep"),
Content: strconv.AppendQuote(nil, "# keep"),
Expand Down
6 changes: 5 additions & 1 deletion pkg/models/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@ var _ = Describe("Installer", func() {
noClusterApplicableManifests, err := NoClusterApplicableManifests(params)
Expect(err).ShouldNot(HaveOccurred())

Expect(len(noClusterApplicableManifests)).Should(Equal(2))
Expect(len(noClusterApplicableManifests)).Should(Equal(3))

expectedManifests := []Manifest{
{
Path: git.GetSystemQualifiedPath(params.ClusterName, SystemKustomizationPath),
Content: systemKustomizationManifest,
},
{
Path: git.GetSystemQualifiedPath(params.ClusterName, WegoProfilesPath),
Content: []byte(""),
},
{
Path: filepath.Join(git.GetUserPath(params.ClusterName), ".keep"),
Content: strconv.AppendQuote(nil, "# keep"),
Expand Down
8 changes: 8 additions & 0 deletions pkg/services/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ var _ = Describe("Installer", func() {
Path: git.GetSystemQualifiedPath(clusterName, models.SystemKustomizationPath),
Content: systemKustomizationManifest,
},
{
Path: git.GetSystemQualifiedPath(clusterName, models.WegoProfilesPath),
Content: []byte(""),
},
{
Path: filepath.Join(git.GetUserPath(clusterName), ".keep"),
Content: strconv.AppendQuote(nil, "# keep"),
Expand Down Expand Up @@ -313,6 +317,10 @@ var _ = Describe("Installer", func() {
Path: git.GetSystemQualifiedPath(clusterName, models.SystemKustomizationPath),
Content: systemKustomizationManifest,
},
{
Path: git.GetSystemQualifiedPath(clusterName, models.WegoProfilesPath),
Content: []byte(""),
},
{
Path: filepath.Join(git.GetUserPath(clusterName), ".keep"),
Content: strconv.AppendQuote(nil, "# keep"),
Expand Down
16 changes: 10 additions & 6 deletions test/acceptance/test/add_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ var _ = Describe("Weave GitOps Add App Tests", func() {

By("Then I should see my workload deployed for app2", func() {
verifyWegoAddCommand(appName2, WEGO_DEFAULT_NAMESPACE)
Expect(waitForResource("apps", appName2, WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)).To(Succeed())
Expect(waitForResource("configmaps", "helloworld-configmap", WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)).To(Succeed())
waitForResourceToExist("apps", appName2, WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)
waitForResourceToExist("configmaps", "helloworld-configmap", WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)
})

By("When I run gitops add app command for app3: "+appName3, func() {
Expand Down Expand Up @@ -871,8 +871,8 @@ var _ = Describe("Weave GitOps Add App Tests", func() {

By("Then I should see my workload deployed to the cluster", func() {
verifyWegoAddCommand(appName, WEGO_DEFAULT_NAMESPACE)
Expect(waitForResource("apps", appName, WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)).To(Succeed())
Expect(waitForResource("configmaps", "helloworld-configmap", WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)).To(Succeed())
waitForResourceToExist("apps", appName, WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)
waitForResourceToExist("configmaps", "helloworld-configmap", WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)
})

By("And repo created has private visibility", func() {
Expand Down Expand Up @@ -934,8 +934,8 @@ var _ = Describe("Weave GitOps Add App Tests", func() {

By("Then I should see my workload deployed to the cluster", func() {
verifyWegoAddCommand(appName, WEGO_DEFAULT_NAMESPACE)
Expect(waitForResource("apps", appName, WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)).To(Succeed())
Expect(waitForResource("configmaps", "helloworld-configmap", WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)).To(Succeed())
waitForResourceToExist("apps", appName, WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)
waitForResourceToExist("configmaps", "helloworld-configmap", WEGO_DEFAULT_NAMESPACE, INSTALL_PODS_READY_TIMEOUT)
})

})
Expand Down Expand Up @@ -1585,6 +1585,10 @@ var _ = Describe("Weave GitOps Add Tests With Long Cluster Name", func() {
installAndVerifyWego(WEGO_DEFAULT_NAMESPACE, configRepoRemoteURL)
})

By("And the kustomizations should not have any errors", func() {
VerifyKustomizations(clusterContext, WEGO_DEFAULT_NAMESPACE)
})

By("And I run gitops add app command for app: "+appName, func() {
runWegoAddCommand(repoAbsolutePath, addCommand, WEGO_DEFAULT_NAMESPACE)
})
Expand Down
10 changes: 6 additions & 4 deletions test/acceptance/test/scripts/kind-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

set -o errexit

echo "Delete existing kind clusters"
kind delete clusters --all
if [[ -z "${SKIP_DELETE}" ]]; then
echo "Delete existing kind clusters"
kind delete clusters --all
fi

echo "Create a new kind cluster with name "$1

Expand All @@ -35,7 +37,7 @@ fi
kind_version=$(kind version)
kind_network='kind'
reg_name='kind-registry'
reg_port='5000'
reg_port='5001'
case "${kind_version}" in
"kind v0.7."* | "kind v0.6."* | "kind v0.5."*)
kind_network='bridge'
Expand Down Expand Up @@ -81,4 +83,4 @@ if [ "${kind_network}" != "bridge" ]; then
if [ "${needs_connect}" = "true" ]; then
docker network connect "${kind_network}" "${reg_name}" || true
fi
fi
fi
4 changes: 0 additions & 4 deletions test/acceptance/test/scripts/kind-multi-cluster.sh

This file was deleted.

Loading

0 comments on commit 4e5b5b1

Please sign in to comment.