mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 04:00:27 +00:00
NOISSUE - Use Magistrala packages instead of SMQ (#24)
* Use Magistrala packages where needed Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Move SMQ scripts to MG Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> --------- Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
This commit is contained in:
@@ -6,9 +6,9 @@ package api
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
api "github.com/absmach/supermq/api/http"
|
||||
apiutil "github.com/absmach/supermq/api/http/util"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
svcerr "github.com/absmach/supermq/pkg/errors/service"
|
||||
|
||||
@@ -18,11 +18,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
bsapi "github.com/absmach/magistrala/bootstrap/api"
|
||||
"github.com/absmach/magistrala/bootstrap/mocks"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
apiutil "github.com/absmach/supermq/api/http/util"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
bsapi "github.com/absmach/supermq/bootstrap/api"
|
||||
"github.com/absmach/supermq/bootstrap/mocks"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
authnmocks "github.com/absmach/supermq/pkg/authn/mocks"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
apiutil "github.com/absmach/supermq/api/http/util"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
)
|
||||
|
||||
const maxLimitSize = 100
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
apiutil "github.com/absmach/supermq/api/http/util"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/supermq"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/supermq"
|
||||
api "github.com/absmach/supermq/api/http"
|
||||
apiutil "github.com/absmach/supermq/api/http/util"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
svcerr "github.com/absmach/supermq/pkg/errors/service"
|
||||
"github.com/absmach/supermq/pkg/events"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package producer
|
||||
|
||||
import (
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/supermq/pkg/events"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ package producer
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/events"
|
||||
)
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap/events/producer"
|
||||
"github.com/absmach/magistrala/bootstrap/mocks"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/supermq/bootstrap/events/producer"
|
||||
"github.com/absmach/supermq/bootstrap/mocks"
|
||||
"github.com/absmach/supermq/pkg/authn"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
|
||||
@@ -6,7 +6,7 @@ package middleware
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/authz"
|
||||
smqauthz "github.com/absmach/supermq/pkg/authz"
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/go-kit/kit/metrics"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
bootstrap "github.com/absmach/supermq/bootstrap"
|
||||
bootstrap "github.com/absmach/magistrala/bootstrap"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ package mocks
|
||||
import (
|
||||
context "context"
|
||||
|
||||
bootstrap "github.com/absmach/supermq/bootstrap"
|
||||
bootstrap "github.com/absmach/magistrala/bootstrap"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
bootstrap "github.com/absmach/supermq/bootstrap"
|
||||
bootstrap "github.com/absmach/magistrala/bootstrap"
|
||||
authn "github.com/absmach/supermq/pkg/authn"
|
||||
|
||||
context "context"
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/supermq/clients"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
repoerr "github.com/absmach/supermq/pkg/errors/repository"
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap/postgres"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/supermq/bootstrap/postgres"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
repoerr "github.com/absmach/supermq/pkg/errors/repository"
|
||||
"github.com/gofrs/uuid/v5"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap/postgres"
|
||||
"github.com/absmach/magistrala/bootstrap/postgres"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
pgclient "github.com/absmach/supermq/pkg/postgres"
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/supermq"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap/mocks"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/supermq/bootstrap/mocks"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
svcerr "github.com/absmach/supermq/pkg/errors/service"
|
||||
|
||||
@@ -6,7 +6,7 @@ package tracing
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
@@ -13,14 +13,14 @@ import (
|
||||
"os"
|
||||
|
||||
chclient "github.com/absmach/callhome/pkg/client"
|
||||
"github.com/absmach/magistrala/bootstrap"
|
||||
httpapi "github.com/absmach/magistrala/bootstrap/api"
|
||||
"github.com/absmach/magistrala/bootstrap/events/consumer"
|
||||
"github.com/absmach/magistrala/bootstrap/events/producer"
|
||||
"github.com/absmach/magistrala/bootstrap/middleware"
|
||||
bootstrappg "github.com/absmach/magistrala/bootstrap/postgres"
|
||||
"github.com/absmach/magistrala/bootstrap/tracing"
|
||||
"github.com/absmach/supermq"
|
||||
"github.com/absmach/supermq/bootstrap"
|
||||
httpapi "github.com/absmach/supermq/bootstrap/api"
|
||||
"github.com/absmach/supermq/bootstrap/events/consumer"
|
||||
"github.com/absmach/supermq/bootstrap/events/producer"
|
||||
"github.com/absmach/supermq/bootstrap/middleware"
|
||||
bootstrappg "github.com/absmach/supermq/bootstrap/postgres"
|
||||
"github.com/absmach/supermq/bootstrap/tracing"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
authsvcAuthn "github.com/absmach/supermq/pkg/authn/authsvc"
|
||||
smqauthz "github.com/absmach/supermq/pkg/authz"
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
|
||||
chclient "github.com/absmach/callhome/pkg/client"
|
||||
"github.com/absmach/magistrala/readers/postgres"
|
||||
"github.com/absmach/supermq"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
"github.com/absmach/supermq/pkg/authn/authsvc"
|
||||
@@ -23,7 +24,6 @@ import (
|
||||
"github.com/absmach/supermq/pkg/uuid"
|
||||
"github.com/absmach/supermq/readers"
|
||||
httpapi "github.com/absmach/supermq/readers/api"
|
||||
"github.com/absmach/supermq/readers/postgres"
|
||||
"github.com/caarlos0/env/v11"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
"os"
|
||||
|
||||
chclient "github.com/absmach/callhome/pkg/client"
|
||||
consumertracing "github.com/absmach/magistrala/consumers/tracing"
|
||||
httpapi "github.com/absmach/magistrala/consumers/writers/api"
|
||||
writerpg "github.com/absmach/magistrala/consumers/writers/postgres"
|
||||
"github.com/absmach/supermq"
|
||||
"github.com/absmach/supermq/consumers"
|
||||
consumertracing "github.com/absmach/supermq/consumers/tracing"
|
||||
httpapi "github.com/absmach/supermq/consumers/writers/api"
|
||||
writerpg "github.com/absmach/supermq/consumers/writers/postgres"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
jaegerclient "github.com/absmach/supermq/pkg/jaeger"
|
||||
"github.com/absmach/supermq/pkg/messaging/brokers"
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
|
||||
chclient "github.com/absmach/callhome/pkg/client"
|
||||
"github.com/absmach/magistrala/readers/timescale"
|
||||
"github.com/absmach/supermq"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
"github.com/absmach/supermq/pkg/authn/authsvc"
|
||||
@@ -23,7 +24,6 @@ import (
|
||||
"github.com/absmach/supermq/pkg/uuid"
|
||||
"github.com/absmach/supermq/readers"
|
||||
httpapi "github.com/absmach/supermq/readers/api"
|
||||
"github.com/absmach/supermq/readers/timescale"
|
||||
"github.com/caarlos0/env/v11"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
"os"
|
||||
|
||||
chclient "github.com/absmach/callhome/pkg/client"
|
||||
consumertracing "github.com/absmach/magistrala/consumers/tracing"
|
||||
httpapi "github.com/absmach/magistrala/consumers/writers/api"
|
||||
"github.com/absmach/magistrala/consumers/writers/timescale"
|
||||
"github.com/absmach/supermq"
|
||||
"github.com/absmach/supermq/consumers"
|
||||
consumertracing "github.com/absmach/supermq/consumers/tracing"
|
||||
httpapi "github.com/absmach/supermq/consumers/writers/api"
|
||||
"github.com/absmach/supermq/consumers/writers/timescale"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
jaegerclient "github.com/absmach/supermq/pkg/jaeger"
|
||||
"github.com/absmach/supermq/pkg/messaging/brokers"
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/consumers/notifiers/api"
|
||||
"github.com/absmach/magistrala/consumers/notifiers/mocks"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
apiutil "github.com/absmach/supermq/api/http/util"
|
||||
"github.com/absmach/supermq/consumers/notifiers"
|
||||
"github.com/absmach/supermq/consumers/notifiers/api"
|
||||
"github.com/absmach/supermq/consumers/notifiers/mocks"
|
||||
smqlog "github.com/absmach/supermq/logger"
|
||||
svcerr "github.com/absmach/supermq/pkg/errors/service"
|
||||
"github.com/absmach/supermq/pkg/uuid"
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) Abstract Machines
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/absmach/supermq/pkg/messaging"
|
||||
)
|
||||
|
||||
// ErrNotify wraps sending notification errors.
|
||||
var ErrNotify = errors.New("error sending notification")
|
||||
|
||||
// Notifier represents an API for sending notification.
|
||||
//
|
||||
//go:generate mockery --name Notifier --output=./mocks --filename notifier.go --quiet --note "Copyright (c) Abstract Machines"
|
||||
type Notifier interface {
|
||||
// Notify method is used to send notification for the
|
||||
// received message to the provided list of receivers.
|
||||
Notify(from string, to []string, msg *messaging.Message) error
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/supermq/consumers/notifiers/postgres"
|
||||
"github.com/absmach/magistrala/consumers/notifiers/postgres"
|
||||
pgclient "github.com/absmach/supermq/pkg/postgres"
|
||||
"github.com/absmach/supermq/pkg/ulid"
|
||||
_ "github.com/jackc/pgx/v5/stdlib" // required for SQL access
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/consumers/notifiers/postgres"
|
||||
"github.com/absmach/supermq/consumers/notifiers"
|
||||
"github.com/absmach/supermq/consumers/notifiers/postgres"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
repoerr "github.com/absmach/supermq/pkg/errors/repository"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/absmach/supermq"
|
||||
"github.com/absmach/supermq/consumers"
|
||||
notif "github.com/absmach/supermq/consumers/notifiers"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
svcerr "github.com/absmach/supermq/pkg/errors/service"
|
||||
@@ -46,13 +47,13 @@ type notifierService struct {
|
||||
authn smqauthn.Authentication
|
||||
subs SubscriptionsRepository
|
||||
idp supermq.IDProvider
|
||||
notifier Notifier
|
||||
notifier notif.Notifier
|
||||
errCh chan error
|
||||
from string
|
||||
}
|
||||
|
||||
// New instantiates the subscriptions service implementation.
|
||||
func New(authn smqauthn.Authentication, subs SubscriptionsRepository, idp supermq.IDProvider, notifier Notifier, from string) Service {
|
||||
func New(authn smqauthn.Authentication, subs SubscriptionsRepository, idp supermq.IDProvider, notifier notif.Notifier, from string) Service {
|
||||
return ¬ifierService{
|
||||
authn: authn,
|
||||
subs: subs,
|
||||
@@ -131,7 +132,7 @@ func (ns *notifierService) ConsumeBlocking(ctx context.Context, message interfac
|
||||
if len(to) > 0 {
|
||||
err := ns.notifier.Notify(ns.from, to, msg)
|
||||
if err != nil {
|
||||
return errors.Wrap(ErrNotify, err)
|
||||
return errors.Wrap(notif.ErrNotify, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +166,7 @@ func (ns *notifierService) ConsumeAsync(ctx context.Context, message interface{}
|
||||
}
|
||||
if len(to) > 0 {
|
||||
if err := ns.notifier.Notify(ns.from, to, msg); err != nil {
|
||||
ns.errCh <- errors.Wrap(ErrNotify, err)
|
||||
ns.errCh <- errors.Wrap(notif.ErrNotify, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/consumers/notifiers/mocks"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
"github.com/absmach/supermq/consumers/notifiers"
|
||||
"github.com/absmach/supermq/consumers/notifiers/mocks"
|
||||
smqauthn "github.com/absmach/supermq/pkg/authn"
|
||||
authnmocks "github.com/absmach/supermq/pkg/authn/mocks"
|
||||
"github.com/absmach/supermq/pkg/errors"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/supermq/consumers/writers/postgres"
|
||||
"github.com/absmach/magistrala/consumers/writers/postgres"
|
||||
"github.com/absmach/supermq/pkg/transformers/json"
|
||||
"github.com/absmach/supermq/pkg/transformers/senml"
|
||||
"github.com/gofrs/uuid/v5"
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/supermq/consumers/writers/postgres"
|
||||
"github.com/absmach/magistrala/consumers/writers/postgres"
|
||||
pgclient "github.com/absmach/supermq/pkg/postgres"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/ory/dockertest/v3"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/absmach/supermq/consumers/writers/timescale"
|
||||
"github.com/absmach/magistrala/consumers/writers/timescale"
|
||||
"github.com/absmach/supermq/pkg/transformers/json"
|
||||
"github.com/absmach/supermq/pkg/transformers/senml"
|
||||
"github.com/gofrs/uuid/v5"
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/supermq/consumers/writers/timescale"
|
||||
"github.com/absmach/magistrala/consumers/writers/timescale"
|
||||
pgclient "github.com/absmach/supermq/pkg/postgres"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/ory/dockertest/v3"
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pwriter "github.com/absmach/magistrala/consumers/writers/postgres"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
pwriter "github.com/absmach/supermq/consumers/writers/postgres"
|
||||
preader "github.com/absmach/magistrala/readers/postgres"
|
||||
"github.com/absmach/supermq/pkg/transformers/json"
|
||||
"github.com/absmach/supermq/pkg/transformers/senml"
|
||||
"github.com/absmach/supermq/readers"
|
||||
preader "github.com/absmach/supermq/readers/postgres"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/supermq/readers/postgres"
|
||||
"github.com/absmach/magistrala/readers/postgres"
|
||||
_ "github.com/jackc/pgx/v5/stdlib" // required for SQL access
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/ory/dockertest/v3"
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
twriter "github.com/absmach/magistrala/consumers/writers/timescale"
|
||||
"github.com/absmach/magistrala/internal/testsutil"
|
||||
twriter "github.com/absmach/supermq/consumers/writers/timescale"
|
||||
treader "github.com/absmach/magistrala/readers/timescale"
|
||||
"github.com/absmach/supermq/pkg/transformers/json"
|
||||
"github.com/absmach/supermq/pkg/transformers/senml"
|
||||
"github.com/absmach/supermq/readers"
|
||||
treader "github.com/absmach/supermq/readers/timescale"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/supermq/readers/timescale"
|
||||
"github.com/absmach/magistrala/readers/timescale"
|
||||
_ "github.com/jackc/pgx/v5/stdlib" // required for SQL access
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/ory/dockertest/v3"
|
||||
|
||||
+5
-5
@@ -49,7 +49,7 @@ setup_protoc() {
|
||||
}
|
||||
|
||||
setup_mg() {
|
||||
echo "Setting up Magistrala..."
|
||||
echo "Setting up SuperMQ..."
|
||||
for p in $(ls *.pb.go); do
|
||||
mv $p $p.tmp
|
||||
done
|
||||
@@ -70,15 +70,15 @@ setup_mg() {
|
||||
fi
|
||||
done
|
||||
echo "Compile check for rabbitmq..."
|
||||
MG_MESSAGE_BROKER_TYPE=rabbitmq make http
|
||||
SMQ_MESSAGE_BROKER_TYPE=rabbitmq make http
|
||||
echo "Compile check for redis..."
|
||||
MG_ES_TYPE=redis make http
|
||||
SMQ_ES_TYPE=redis make http
|
||||
make -j$NPROC
|
||||
}
|
||||
|
||||
setup_lint() {
|
||||
# binary will be $(go env GOBIN)/golangci-lint
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOBIN) $GOLANGCI_LINT_VERSION
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/main/install.sh | sh -s -- -b $(go env GOBIN) $GOLANGCI_LINT_VERSION
|
||||
}
|
||||
|
||||
setup() {
|
||||
@@ -105,7 +105,7 @@ run_test() {
|
||||
}
|
||||
|
||||
push() {
|
||||
if test -n "$BRANCH_NAME" && test "$BRANCH_NAME" = "master"; then
|
||||
if test -n "$BRANCH_NAME" && test "$BRANCH_NAME" = "main"; then
|
||||
echo "Pushing Docker images..."
|
||||
make -j$NPROC latest
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
channel_1
|
||||
channel_2
|
||||
channel_3
|
||||
|
@@ -0,0 +1,10 @@
|
||||
client_1
|
||||
client_2
|
||||
client_3
|
||||
client_4
|
||||
client_5
|
||||
client_6
|
||||
client_7
|
||||
client_8
|
||||
client_9
|
||||
client_10
|
||||
|
+15
-15
@@ -5,9 +5,9 @@
|
||||
#
|
||||
|
||||
###
|
||||
# Provisions example user, thing and channel on a clean Magistrala installation.
|
||||
# Provisions example user, client and channel on a clean SuperMQ installation.
|
||||
#
|
||||
# Expects a running Magistrala installation.
|
||||
# Expects a running SuperMQ installation.
|
||||
#
|
||||
#
|
||||
###
|
||||
@@ -25,26 +25,26 @@ CHANNEL=$4
|
||||
|
||||
#provision user:
|
||||
printf "Provisoning user with email $EMAIL and password $PASSWORD \n"
|
||||
curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users -d '{"credentials": {"identity": "'"$EMAIL"'","secret": "'"$PASSWORD"'"}, "status": "enabled", "role": "admin" }'
|
||||
curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users -d '{"credentials": {"identity": "'"$EMAIL"'","secret": "'"$PASSWORD"'"}, "status": "enabled", "role": "admin" }'
|
||||
|
||||
#get jwt token
|
||||
JWTTOKEN=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users/tokens/issue -d '{"identity":"'"$EMAIL"'", "secret":"'"$PASSWORD"'"}' | grep -oP '"access_token":"\K[^"]+' )
|
||||
JWTTOKEN=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users/tokens/issue -d '{"identity":"'"$EMAIL"'", "secret":"'"$PASSWORD"'"}' | grep -oP '"access_token":"\K[^"]+' )
|
||||
printf "JWT TOKEN for user is $JWTTOKEN \n"
|
||||
|
||||
#provision thing
|
||||
printf "Provisioning thing with name $DEVICE \n"
|
||||
DEVICEID=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/things -d '{"name":"'"$DEVICE"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' )
|
||||
curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/things/$DEVICEID
|
||||
#provision client
|
||||
printf "Provisioning client with name $DEVICE \n"
|
||||
DEVICEID=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/clients -d '{"name":"'"$DEVICE"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' )
|
||||
curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/clients/$DEVICEID
|
||||
|
||||
#get thing token
|
||||
DEVICETOKEN=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -H "Authorization: Bearer $JWTTOKEN" https://localhost/things/$DEVICEID | grep -oP '"secret":"\K[^"]+' )
|
||||
#get client token
|
||||
DEVICETOKEN=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -H "Authorization: Bearer $JWTTOKEN" https://localhost/clients/$DEVICEID | grep -oP '"secret":"\K[^"]+' )
|
||||
printf "Device token is $DEVICETOKEN \n"
|
||||
|
||||
#provision channel
|
||||
printf "Provisioning channel with name $CHANNEL \n"
|
||||
CHANNELID=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels -d '{"name":"'"$CHANNEL"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' )
|
||||
curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID
|
||||
CHANNELID=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels -d '{"name":"'"$CHANNEL"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' )
|
||||
curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID
|
||||
|
||||
#connect thing to channel
|
||||
printf "Connecting thing of id $DEVICEID to channel of id $CHANNELID \n"
|
||||
curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X PUT -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID/things/$DEVICEID
|
||||
#connect client to channel
|
||||
printf "Connecting client of id $DEVICEID to channel of id $CHANNELID \n"
|
||||
curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X PUT -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID/clients/$DEVICEID
|
||||
|
||||
+10
-10
@@ -3,7 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
###
|
||||
# Runs all Magistrala microservices (must be previously built and installed).
|
||||
# Runs all SuperMQ microservices (must be previously built and installed).
|
||||
#
|
||||
# Expects that PostgreSQL and needed messaging DB are alredy running.
|
||||
# Additionally, MQTT microservice demands that Redis is up and running.
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
BUILD_DIR=../build
|
||||
|
||||
# Kill all magistrala-* stuff
|
||||
# Kill all supermq-* stuff
|
||||
function cleanup {
|
||||
pkill magistrala
|
||||
pkill supermq
|
||||
pkill nats
|
||||
}
|
||||
|
||||
@@ -38,32 +38,32 @@ done
|
||||
###
|
||||
# Users
|
||||
###
|
||||
MG_USERS_LOG_LEVEL=info MG_USERS_HTTP_PORT=9002 MG_USERS_GRPC_PORT=7001 MG_USERS_ADMIN_EMAIL=admin@magistrala.com MG_USERS_ADMIN_PASSWORD=12345678 MG_USERS_ADMIN_USERNAME=admin MG_EMAIL_TEMPLATE=../docker/templates/users.tmpl $BUILD_DIR/magistrala-users &
|
||||
SMQ_USERS_LOG_LEVEL=info SMQ_USERS_HTTP_PORT=9002 SMQ_USERS_GRPC_PORT=7001 SMQ_USERS_ADMIN_EMAIL=admin@supermq.com SMQ_USERS_ADMIN_PASSWORD=12345678 SMQ_USERS_ADMIN_USERNAME=admin SMQ_EMAIL_TEMPLATE=../docker/templates/users.tmpl $BUILD_DIR/supermq-users &
|
||||
|
||||
###
|
||||
# Things
|
||||
# Clients
|
||||
###
|
||||
MG_THINGS_LOG_LEVEL=info MG_THINGS_HTTP_PORT=9000 MG_THINGS_AUTH_GRPC_PORT=7000 MG_THINGS_AUTH_HTTP_PORT=9002 $BUILD_DIR/magistrala-things &
|
||||
SMQ_CLIENTS_LOG_LEVEL=info SMQ_CLIENTS_HTTP_PORT=9000 SMQ_CLIENTS_AUTH_GRPC_PORT=7000 SMQ_CLIENTS_AUTH_HTTP_PORT=9002 $BUILD_DIR/supermq-clients &
|
||||
|
||||
###
|
||||
# HTTP
|
||||
###
|
||||
MG_HTTP_ADAPTER_LOG_LEVEL=info MG_HTTP_ADAPTER_PORT=8008 MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-http &
|
||||
SMQ_HTTP_ADAPTER_LOG_LEVEL=info SMQ_HTTP_ADAPTER_PORT=8008 SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-http &
|
||||
|
||||
###
|
||||
# WS
|
||||
###
|
||||
MG_WS_ADAPTER_LOG_LEVEL=info MG_WS_ADAPTER_HTTP_PORT=8190 MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-ws &
|
||||
SMQ_WS_ADAPTER_LOG_LEVEL=info SMQ_WS_ADAPTER_HTTP_PORT=8190 SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-ws &
|
||||
|
||||
###
|
||||
# MQTT
|
||||
###
|
||||
MG_MQTT_ADAPTER_LOG_LEVEL=info MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-mqtt &
|
||||
SMQ_MQTT_ADAPTER_LOG_LEVEL=info SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-mqtt &
|
||||
|
||||
###
|
||||
# CoAP
|
||||
###
|
||||
MG_COAP_ADAPTER_LOG_LEVEL=info MG_COAP_ADAPTER_PORT=5683 MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-coap &
|
||||
SMQ_COAP_ADAPTER_LOG_LEVEL=info SMQ_COAP_ADAPTER_PORT=5683 SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-coap &
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user