Skip to content

Commit

Permalink
Test and remove junk
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Feb 8, 2019
1 parent 23c3e6d commit a8f280d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 31 deletions.
6 changes: 3 additions & 3 deletions deploy/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ rules:
verbs:
- '*'
- apiGroups:
- jaeger.openshift.io
- io.jaegertracing.elasticsearch
resources:
- jaeger
- jaeger
verbs:
- 'get'
- 'get'
6 changes: 3 additions & 3 deletions pkg/account/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func Get(jaeger *v1alpha1.Jaeger) []*v1.ServiceAccount {
if jaeger.Spec.Ingress.Security == v1alpha1.IngressSecurityOAuthProxy {
accounts = append(accounts, OAuthProxy(jaeger))
}
return append(accounts, main(jaeger))
return append(accounts, getMain(jaeger))
}

func main(jaeger *v1alpha1.Jaeger) *v1.ServiceAccount {
func getMain(jaeger *v1alpha1.Jaeger) *v1.ServiceAccount {
trueVar := true
return &v1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -38,5 +38,5 @@ func main(jaeger *v1alpha1.Jaeger) *v1.ServiceAccount {
}

func JaegerServiceAccountFor(jaeger *v1alpha1.Jaeger) string {
return fmt.Sprintf("jaeger-%s", jaeger.Name)
return fmt.Sprintf("%s", jaeger.Name)
}
16 changes: 12 additions & 4 deletions pkg/account/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ import (
func TestWithSecurityNil(t *testing.T) {
jaeger := v1alpha1.NewJaeger("TestWithOAuthProxyNil")
assert.Equal(t, v1alpha1.IngressSecurityNone, jaeger.Spec.Ingress.Security)
assert.Len(t, Get(jaeger), 0)
sas := Get(jaeger)
assert.Len(t, sas, 1)
assert.Equal(t, getMain(jaeger), sas[0])
}

func TestWithSecurityNone(t *testing.T) {
jaeger := v1alpha1.NewJaeger("TestWithOAuthProxyFalse")
jaeger.Spec.Ingress.Security = v1alpha1.IngressSecurityNone

assert.Len(t, Get(jaeger), 0)
sas := Get(jaeger)
assert.Len(t, sas, 1)
assert.Equal(t, getMain(jaeger), sas[0])
}

func TestWithSecurityOAuthProxy(t *testing.T) {
jaeger := v1alpha1.NewJaeger("TestWithOAuthProxyTrue")
jaeger.Spec.Ingress.Security = v1alpha1.IngressSecurityOAuthProxy

assert.Len(t, Get(jaeger), 1)
assert.Len(t, Get(jaeger), 2)
}

func TestJaegerName(t *testing.T) {
jaeger := v1alpha1.NewJaeger("foo")
assert.Equal(t, "foo", JaegerServiceAccountFor(jaeger))
}
6 changes: 1 addition & 5 deletions pkg/inject/oauth-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ func getOAuthProxyContainer(jaeger *v1alpha1.Jaeger) v1.Container {
VolumeMounts: []v1.VolumeMount{{
MountPath: "/etc/tls/private",
Name: service.GetTLSSecretNameForQueryService(jaeger),
},
{
MountPath: "/sec",
Name: "es-secrets",
}},
}},
Ports: []v1.ContainerPort{
{
ContainerPort: 8443,
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ func Dependencies(jaeger *v1alpha1.Jaeger) []batchv1.Job {
if strings.ToLower(jaeger.Spec.Storage.Type) == "cassandra" {
return cassandraDeps(jaeger)
}

return []batchv1.Job{}
}
4 changes: 2 additions & 2 deletions pkg/storage/elasticsearch_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func GetESRoles(jaeger *v1alpha1.Jaeger, dep ...*appsv1.Deployment) []runtime.Ob
// The SG invokes this API to allow the request
// TOKEN=$(oc serviceaccounts get-token jaeger-simple-prod)
// curl -k -v -XPOST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" https://127.0.0.1:8443/apis/authorization.k8s.io/v1/selfsubjectaccessreviews -d '{"kind":"SelfSubjectAccessReview","apiVersion":"authorization.k8s.io/v1","spec":{"resourceAttributes":{"group":"jaeger.openshift.io","verb":"get","resource":"jaeger"}}}'
APIGroups: []string{"jaeger.openshift.io"},
APIGroups: []string{"io.jaegertracing.elasticsearch"},
Resources: []string{"jaeger"},
Verbs: []string{"get"},
},
Expand All @@ -37,7 +37,7 @@ func GetESRoles(jaeger *v1alpha1.Jaeger, dep ...*appsv1.Deployment) []runtime.Ob
for _, d := range dep {
rb := &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-%s", roleName, d.Name),
Name: fmt.Sprintf("%s:%s", roleName, d.Spec.Template.Spec.ServiceAccountName),
Namespace: jaeger.Namespace,
OwnerReferences: []metav1.OwnerReference{asOwner(jaeger)},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/strategy/all-in-one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestDelegateAllInOneDepedencies(t *testing.T) {
func assertDeploymentsAndServicesForAllInOne(t *testing.T, name string, objs []runtime.Object, hasDaemonSet bool, hasOAuthProxy bool, hasConfigMap bool) {
// TODO(jpkroehling): this func deserves a refactoring already

expectedNumObjs := 6
expectedNumObjs := 7

if hasDaemonSet {
expectedNumObjs++
Expand Down
8 changes: 4 additions & 4 deletions pkg/strategy/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestNewControllerForProduction(t *testing.T) {

ctrl := For(context.TODO(), jaeger)
ds := ctrl.Create()
assert.Len(t, ds, 6)
assert.Len(t, ds, 7)
}

func TestUnknownStorage(t *testing.T) {
Expand Down Expand Up @@ -270,9 +270,9 @@ func assertHasAllObjects(t *testing.T, name string, objs []runtime.Object, deplo
assert.True(t, v, "Expected %s to have been returned from the list of ingress rules", k)
}

//for k, v := range routes {
// assert.True(t, v, "Expected %s to have been returned from the list of routes", k)
//}
for k, v := range routes {
assert.True(t, v, "Expected %s to have been returned from the list of routes", k)
}

for k, v := range serviceAccounts {
assert.True(t, v, "Expected %s to have been returned from the list of service accounts", k)
Expand Down
7 changes: 4 additions & 3 deletions pkg/strategy/production.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/jaegertracing/jaeger-operator/pkg/deployment"
"github.com/jaegertracing/jaeger-operator/pkg/ingress"
"github.com/jaegertracing/jaeger-operator/pkg/inject"
"github.com/jaegertracing/jaeger-operator/pkg/route"
"github.com/jaegertracing/jaeger-operator/pkg/storage"
)

Expand Down Expand Up @@ -76,9 +77,9 @@ func (c *productionStrategy) Create() []runtime.Object {

// add the routes/ingresses
if viper.GetString("platform") == v1alpha1.FlagPlatformOpenShift {
//if q := route.NewQueryRoute(c.jaeger).Get(); nil != q {
// os = append(os, q)
//}
if q := route.NewQueryRoute(c.jaeger).Get(); nil != q {
os = append(os, q)
}
} else {
if q := ingress.NewQueryIngress(c.jaeger).Get(); nil != q {
os = append(os, q)
Expand Down
10 changes: 5 additions & 5 deletions pkg/strategy/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ func TestDelegateProductionDepedencies(t *testing.T) {
}

func assertDeploymentsAndServicesForProduction(t *testing.T, name string, objs []runtime.Object, hasDaemonSet bool, hasOAuthProxy bool, hasConfigMap bool) {
expectedNumObjs := 6
expectedNumObjs := 7

if hasDaemonSet {
expectedNumObjs++
}

//if hasOAuthProxy {
// expectedNumObjs++
//}
if hasOAuthProxy {
expectedNumObjs++
}

if hasConfigMap {
expectedNumObjs++
Expand Down Expand Up @@ -161,7 +161,7 @@ func assertDeploymentsAndServicesForProduction(t *testing.T, name string, objs [
ingresses[fmt.Sprintf("%s-query", name)] = false
}

serviceAccounts := map[string]bool{}
serviceAccounts := map[string]bool{fmt.Sprintf("%s", name): false}
if hasOAuthProxy {
serviceAccounts[fmt.Sprintf("%s-ui-proxy", name)] = false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/strategy/streaming_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestDelegateStreamingDepedencies(t *testing.T) {
}

func assertDeploymentsAndServicesForStreaming(t *testing.T, name string, objs []runtime.Object, hasDaemonSet bool, hasOAuthProxy bool, hasConfigMap bool) {
expectedNumObjs := 6
expectedNumObjs := 7

if hasDaemonSet {
expectedNumObjs++
Expand Down

0 comments on commit a8f280d

Please sign in to comment.