Beispiel #1
0
    def setUp(self):
        super(MonitoringChecksTestCase, self).setUp()

        populate()
        self.host, _ = Host.objects.get_or_create(name='localhost',
                                                  ip='127.0.0.1')
        self.service_type = ServiceType.objects.get(
            name=ServiceType.TYPE_GEONODE)
        self.service, _ = Service.objects.get_or_create(
            name=settings.MONITORING_SERVICE_NAME,
            host=self.host,
            service_type=self.service_type)
        self.metric = Metric.objects.get(name='request.count')
        self.user = '******'
        self.passwd = 'admin'
        self.u, _ = get_user_model().objects.get_or_create(username=self.user)
        self.u.is_active = True
        self.u.email = '*****@*****.**'
        self.u.set_password(self.passwd)
        self.u.save()
        self.user2 = 'test'
        self.passwd2 = 'test'
        self.u2, _ = get_user_model().objects.get_or_create(
            username=self.user2)
        self.u2.is_active = True
        self.u2.email = '*****@*****.**'
        self.u2.set_password(self.passwd2)
        self.u2.save()
Beispiel #2
0
def run_setup_hooks(*args, **kwargs):
    from django.utils import timezone
    from geonode.monitoring.models import populate

    # Initialize periodic tasks
    if 'django_celery_beat' in settings.INSTALLED_APPS and \
            getattr(settings, 'CELERY_BEAT_SCHEDULER', None) == 'django_celery_beat.schedulers:DatabaseScheduler':
        from django_celery_beat.models import (
            IntervalSchedule,
            PeriodicTask,
        )

        check_intervals = IntervalSchedule.objects.filter(every=300,
                                                          period="seconds")
        if not check_intervals.exists():
            check_interval, _ = IntervalSchedule.objects.get_or_create(
                every=300, period="seconds")
        else:
            check_interval = check_intervals.first()

        PeriodicTask.objects.update_or_create(
            name="collect_metrics",
            defaults=dict(task="geonode.monitoring.tasks.collect_metrics",
                          interval=check_interval,
                          args='',
                          start_time=timezone.now()))

    # Initialize notifications
    if not has_notifications:
        log.warning("Monitoring requires notifications app to be enabled. "
                    "Otherwise, no notifications will be send")
    populate()
Beispiel #3
0
    def setUp(self):
        super(MonitoringAnalyticsTestCase, self).setUp()

        self.user = '******'
        self.passwd = 'admin'
        self.u, _ = get_user_model().objects.get_or_create(username=self.user)
        self.u.is_active = True
        self.u.email = '*****@*****.**'
        self.u.set_password(self.passwd)
        self.u.save()
        self.ua = ("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"
                   "(KHTML, like Gecko) Chrome/59.0.3071.47 Safari/537.36")

        populate()

        self.host, _ = Host.objects.get_or_create(name='localhost',
                                                  ip='127.0.0.1')
        self.service_type = ServiceType.objects.get(
            name=ServiceType.TYPE_GEONODE)
        self.service, _ = Service.objects.get_or_create(
            name=settings.MONITORING_SERVICE_NAME,
            host=self.host,
            service_type=self.service_type)

        file_upload(
            os.path.join(gisdata.VECTOR_DATA,
                         "san_andres_y_providencia_poi.shp"),
            name="san_andres_y_providencia_poi",
            user=self.u,
            overwrite=True,
        )
Beispiel #4
0
    def setUp(self):
        super(MonitoringChecksTestCase, self).setUp()

        populate()
        self.host, _ = Host.objects.get_or_create(
            name='localhost', ip='127.0.0.1')
        self.service_type = ServiceType.objects.get(
            name=ServiceType.TYPE_GEONODE)
        self.service, _ = Service.objects.get_or_create(
            name=settings.MONITORING_SERVICE_NAME,
            host=self.host,
            service_type=self.service_type)
        self.metric = Metric.objects.get(name='request.count')
        self.user = '******'
        self.passwd = 'admin'
        self.u, _ = get_user_model().objects.get_or_create(username=self.user)
        self.u.is_active = True
        self.u.email = '*****@*****.**'
        self.u.set_password(self.passwd)
        self.u.save()
        self.user2 = 'test'
        self.passwd2 = 'test'
        self.u2, _ = get_user_model().objects.get_or_create(
            username=self.user2)
        self.u2.is_active = True
        self.u2.email = '*****@*****.**'
        self.u2.set_password(self.passwd2)
        self.u2.save()
Beispiel #5
0
    def setUp(self):
        super(RequestsTestCase, self).setUp()

        self.user = '******'
        self.passwd = 'admin'
        self.u, _ = get_user_model().objects.get_or_create(username=self.user)
        self.u.is_active = True
        self.u.email = '*****@*****.**'
        self.u.set_password(self.passwd)
        self.u.save()
        self.ua = ("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"
                   "(KHTML, like Gecko) Chrome/59.0.3071.47 Safari/537.36")
        populate()

        self.host, _ = Host.objects.get_or_create(name='localhost',
                                                  ip='127.0.0.1')
        self.service_type = ServiceType.objects.get(
            name=ServiceType.TYPE_GEONODE)
        self.service, _ = Service.objects.get_or_create(
            name=settings.MONITORING_SERVICE_NAME,
            host=self.host,
            service_type=self.service_type)
Beispiel #6
0
    def setUp(self):
        super(RequestsTestCase, self).setUp()

        self.user = '******'
        self.passwd = 'admin'
        self.u, _ = get_user_model().objects.get_or_create(username=self.user)
        self.u.is_active = True
        self.u.email = '*****@*****.**'
        self.u.set_password(self.passwd)
        self.u.save()
        self.ua = ("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"
                   "(KHTML, like Gecko) Chrome/59.0.3071.47 Safari/537.36")
        populate()

        self.host, _ = Host.objects.get_or_create(
            name='localhost', ip='127.0.0.1')
        self.service_type = ServiceType.objects.get(
            name=ServiceType.TYPE_GEONODE)
        self.service, _ = Service.objects.get_or_create(
            name=settings.MONITORING_SERVICE_NAME,
            host=self.host,
            service_type=self.service_type)
Beispiel #7
0
def run_setup_hooks(*args, **kwargs):
    if not has_notifications:
        log.warning("Monitoring requires notifications app to be enabled. "
                    "Otherwise, no notifications will be send")
    from geonode.monitoring.models import populate
    populate()
Beispiel #8
0
def run_setup_hooks(*args, **kwargs):
    if not has_notifications:
        log.warning("Monitoring requires notifications app to be enabled. "
                    "Otherwise, no notifications will be send")
    from geonode.monitoring.models import populate
    populate()