Skip to content

nntp-mongodb_test is a Go program that demonstrates the usage of the nntp-mongodb-storage module. It includes test cases for inserting and deleting articles in MongoDB, as well as showcasing compression options for article storage.

License

go-while/nntp-mongodb_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDBTest - MongoDB Usenet Article Storage Test

mongodbtest is a Go program that tests article insertion, retrieval, and deletion in a MongoDB database for NNTP servers.

It utilizes the nntp-mongodb-storage package to handle storage operations and provides various test cases to evaluate different aspects of the MongoDB storage.

Test Prerequisites

Before running the mongodbtest.go script, make sure you have the following prerequisites installed:

Go Programming Language: Install Go from the official website (https://golang.org/dl/) and set up your Go environment.

MongoDB: Ensure you have a running MongoDB server accessible at the specified URI (MongoURI).

The MongoDB connection URI should include the necessary authentication details and the address of the MongoDB server.

Test Installation

You can clone this repository and build the test program using the following commands:

# go get github.com/go-while/nntp-mongodb-storage
# git clone https://github.com/go-while/nntp-mongodb_test
cd nntp-mongodb_test
go build -o mongodbtest mongodbtest.go

Test Usage

To run the test program, execute the compiled binary:

./mongodbtest # runs all defined 'testCases' in mongodbtest.go

Test Cases

The test program supports the following test cases:

  • "read": Tests article retrieval from the MongoDB collection based on the given MessageID.
  • "delete": Tests article deletion from the MongoDB collection based on the given MessageID.
  • "no-compression": Inserts articles without any compression.
  • "gzip": Inserts articles with gzip compression.
  • "zlib": Inserts articles with zlib compression.
  • Set the number of test iterations using the -test-num flag.
./mongodbtest -test-case=<test-case> -test-num=<num>

The test program will perform the following steps:

1. Load MongoDB storage with the default configurations.
2. Iterate over the specified number of inserts (default: 5000000).
3. For each insert, generate an example article with a unique MessageID and MessageID.
4. Perform different actions based on the specified test case:
   - "read": Read existing articles with the given MessageID.
   - "delete": Delete existing articles with the given MessageID.
   - "no-compression": Insert articles without any compression.
   - "gzip": Insert articles with gzip compression.
   - "zlib": Insert articles with zlib compression.

compression tests at level 3:

  • negative diff: compression not effective
j=9) caseToTest=gzip AFTER GZIP Headsize=178 s1=176 diff1=-2 Bodysize=95 s2=84 diff2=-11
j=9) caseToTest=gzip AFTER GZIP Headsize=177 s1=176 diff1=-1 Bodysize=95 s2=84 diff2=-11

j=15) caseToTest=zlib AFTER ZLIB Headsize=166 s1=176 diff1=10 Bodysize=83 s2=84 diff2=1
j=15) caseToTest=zlib AFTER ZLIB Headsize=165 s1=176 diff1=11 Bodysize=83 s2=84 diff2=1

j=21) caseToTest=flate AFTER FLATE Headsize=155 s1=176 diff1=21 Bodysize=72 s2=84 diff2=12
j=21) caseToTest=flate AFTER FLATE Headsize=154 s1=176 diff1=22 Bodysize=72 s2=84 diff2=12

Disclaimer

Please note that this test program and the module https://github.com/go-while/nntp-mongodb-storage were mostly generated by an AI language model (OpenAI's GPT-3.5, based on GPT-3) for demonstration purposes.

While efforts have been made to ensure its correctness, it is always recommended to review and validate the code before using it in production environments.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

go-while

About

nntp-mongodb_test is a Go program that demonstrates the usage of the nntp-mongodb-storage module. It includes test cases for inserting and deleting articles in MongoDB, as well as showcasing compression options for article storage.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published