コード例 #1
0
ファイル: Server_test.go プロジェクト: venicegeo/pz-logger
func (suite *LoggerTester) Test06OtherParams() {
	t := suite.T()
	assert := assert.New(t)

	suite.setupFixture()
	defer suite.teardownFixture()

	client := suite.client

	client.SetService("myservice", "1.2.3.4")

	sometime := time.Now()

	var testData = []Message{
		{
			Address:   "gnemud7smfv/10.254.0.66",
			Message:   "Received Message to Relay on topic Request-Job with key f3b63085-b482-4ae8-8297-3c7d1fcfff7d",
			Service:   "Dispatcher",
			Severity:  "Info",
			CreatedOn: sometime,
		}, {
			Address:   "gnfbnqsn5m9/10.254.0.14",
			Message:   "Processed Update Status for Job 6d0ea538-4382-4ea5-9669-56519b8c8f58 with Status Success",
			Service:   "JobManager",
			Severity:  "Info",
			CreatedOn: sometime,
		}, {
			Address:   "0.0.0.0",
			Message:   "generated 1: 09d4ec60-ea61-4066-8697-5568a47f84bf",
			Service:   "pz-uuidgen",
			Severity:  "Info",
			CreatedOn: sometime,
		}, {
			Address:   "gnfbnqsn5m9/10.254.0.14",
			Message:   "Handling Job with Topic Create-Job for Job ID 09d4ec60-ea61-4066-8697-5568a47f84bf",
			Service:   "JobManager",
			Severity:  "Info",
			CreatedOn: sometime,
		}, {
			Address:   "gnfbnqsn5m9/10.254.0.14",
			Message:   "Handling Job with Topic Update-Job for Job ID be4ce034-1187-4a4f-95a9-a9c31826248b",
			Service:   "JobManager",
			Severity:  "Info",
			CreatedOn: sometime,
		},
	}

	for _, e := range testData {
		err := client.PostMessage(&e)
		assert.NoError(err)
	}
	httpMessage, _ := json.Marshal(testData[0])
	_, body, _, err := piazza.HTTP(piazza.POST, fmt.Sprintf("localhost:%s/message", piazza.LocalPortNumbers[piazza.PzLogger]), piazza.NewHeaderBuilder().AddJsonContentType().GetHeader(), bytes.NewReader(httpMessage))
	assert.NoError(err)
	println(string(body))
	/*
		sleep()

		format := piazza.JsonPagination{
			PerPage: 100,
			Page:    0,
			Order:   piazza.SortOrderDescending,
			SortBy:  "createdOn",
		}

		params := piazza.HttpQueryParams{}
		params.AddString("service", "JobManager")
		params.AddString("contains", "Success")

		msgs, count, err := client.GetMessages(&format, &params)
		assert.NoError(err)
		assert.Len(msgs, 1)
		assert.Equal(5, count)
	*/
}
コード例 #2
0
ファイル: Server_test.go プロジェクト: venicegeo/pz-logger
func (suite *LoggerTester) Test04Admin() {
	t := suite.T()
	assert := assert.New(t)

	suite.setupFixture()
	defer suite.teardownFixture()

	client := suite.client

	_, err := client.GetStats()
	assert.NoError(err, "GetFromAdminStats")
	_, _, _, err = piazza.HTTP(piazza.GET, fmt.Sprintf("localhost:%s/admin/stats", piazza.LocalPortNumbers[piazza.PzLogger]), piazza.NewHeaderBuilder().AddJsonContentType().GetHeader(), nil)
	assert.NoError(err)

}
コード例 #3
0
ファイル: Server_test.go プロジェクト: venicegeo/pz-logger
func (suite *LoggerTester) Test05Pagination() {
	t := suite.T()
	assert := assert.New(t)

	suite.setupFixture()
	defer suite.teardownFixture()

	client := suite.client

	client.SetService("myservice", "1.2.3.4")

	client.Debug("d")
	client.Info("i")
	client.Warn("w")
	client.Error("e")
	client.Fatal("f")
	sleep()

	format := piazza.JsonPagination{
		PerPage: 1,
		Page:    0,
		SortBy:  "createdOn",
		Order:   piazza.SortOrderDescending,
	}
	ms, count, err := client.GetMessages(&format, nil)
	assert.NoError(err)
	_, _, _, err = piazza.HTTP(piazza.GET, fmt.Sprintf("localhost:%s/message?page=0", piazza.LocalPortNumbers[piazza.PzLogger]), piazza.NewHeaderBuilder().AddJsonContentType().GetHeader(), nil)
	assert.NoError(err)

	assert.Len(ms, 1)
	assert.EqualValues(SeverityDebug, ms[0].Severity)
	assert.Equal(5, count)

	format = piazza.JsonPagination{
		PerPage: 5,
		Page:    0,
		SortBy:  "createdOn",
		Order:   piazza.SortOrderAscending,
	}
	ms, count, err = client.GetMessages(&format, nil)
	assert.NoError(err)
	assert.Len(ms, 5)
	assert.EqualValues(SeverityFatal, ms[4].Severity)
	assert.Equal(5, count)

	format = piazza.JsonPagination{
		PerPage: 3,
		Page:    1,
		SortBy:  "createdOn",
		Order:   piazza.SortOrderDescending,
	}
	ms, count, err = client.GetMessages(&format, nil)
	assert.NoError(err)
	assert.Len(ms, 2)

	assert.EqualValues(SeverityError, ms[1].Severity)
	assert.EqualValues(SeverityFatal, ms[0].Severity)
	assert.Equal(5, count)
}
コード例 #4
0
ファイル: Server_test.go プロジェクト: venicegeo/pz-logger
func (suite *LoggerTester) Test01Version() {
	t := suite.T()
	assert := assert.New(t)

	suite.setupFixture()
	defer suite.teardownFixture()

	client := suite.client

	version, err := client.GetVersion()
	assert.NoError(err)
	assert.EqualValues("1.0.0", version.Version)
	_, _, _, err = piazza.HTTP(piazza.GET, fmt.Sprintf("localhost:%s/version", piazza.LocalPortNumbers[piazza.PzLogger]), piazza.NewHeaderBuilder().AddJsonContentType().GetHeader(), nil)
	assert.NoError(err)
}