In a manufacturing system, production control-related decision-making activities occur at different levels. At the process level, one of the main control activities is to tune the parameters of individual manufacturing equipment. At the system level, the main activity is to coordinate production resources and to route parts to appropriate workstations based on their processing requirement, priority indices, and control policy. At the factory level, the goal is to plan and schedule the processing of parts at different operations for the entire system in order to optimize certain objectives. Note that the results of such activities at different levels are closely coupled and affect the overall performance of the manufacturing system as a whole. Therefore, it is important to systematically integrate these control and optimization activities into one unified platform to ensure the goal of each individual activity is aligned with the overall performance of the system. In this paper, we develop a simulation-based virtual testbed that implements dynamic optimization, automatic information exchange, and decision-making from the process-level, system-level, and factory-level of a manufacturing system into an integrated computation environment. This is demonstrated by connecting a Python-based numerical computation program, discrete-event simulation software (Simul8), and an optimization solver (CPLEX) via a third-party master program. The application of this simulation-based virtual testbed is illustrated by a case study in a machining shop.